From patchwork Sun Nov 19 16:23:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13460485 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="NdejL8Kz" Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (mail-centralusazon11020002.outbound.protection.outlook.com [52.101.61.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A96D137; Sun, 19 Nov 2023 08:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IfmKj/w5pmraX5KBI5eTsyThQfFVQefuXCY9BOUiWooCQCuZwAIgC/PezKIKbJT/gmbUBnpThSWNkgttcRXOUVwq1Ej5MoQNYMVmpqYiq2pXllArQaiYNu2afJPm3Fz81/G7JaVcjXcp3AvZcfgKntxU++FGrlbFbs1/wXCOdEPUatVe2nwTYlii3RtgHnigolDqyFDasdocXsK2YmqPJLO2So+tLT3DcMvmkPtVMRIn0hubURhPnY/CO8V04YKLkCNYBbkxD5Q3m5HUyx4hlBqKU/i64s9zGL2NsEPiP5n2n4HJlyYJk0KysDvNZ9PXCfSmSLI/pXPyykjvp9QGMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0GEkjXHGC9FQG4Qf2zMbjQHGohPt660nYMttpj3dN98=; b=VyPt5FZVFVfOt7D88Wccr1zxYM/W0aBCuCb5ryOVRPun722TRu6SCHBvo9rLD9hKqz/5RcI3Fvloon4+BaPdcXvc++oLLqfRXC5ySXFpwnlUpmeUk+jfzPikoZhX18ZHOkl8jfK7son9ibOUAJNn3Nq7JUtP0njW5tVsX+0G9bDFAb3BMvergVaRQeu6FwdaK4ABle1vqPxFGANETA63VqC3RMIBybJRFBW1Yozyx50B/0boWaaGN4y9Q7vF0WJU8yggo2Ktup99Ku7HLSOFOrCwIQG4OjXHqa6Iba8WSuw931yPnVPaXGm78jwgGD9DLAr7aQJMtU0dTARAJz1L9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0GEkjXHGC9FQG4Qf2zMbjQHGohPt660nYMttpj3dN98=; b=NdejL8Kz05NYDkirjyRA3nFVCn/NUfqTIygoi5hKM1LlBEs2NvvZ1mOE2hSN3LwJ9CWvt7Am3WzExhruSY72IZXhcCei6/BemL4vlZ/0T2Q/+Qujj0vAdXAN7EyEe7D1X2pZ8VUgL/KWa9iv3lvVkCX+PTOuEAGJPUHJLhxLZ5A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by BY1PR21MB3893.namprd21.prod.outlook.com (2603:10b6:a03:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.8; Sun, 19 Nov 2023 16:24:24 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20%3]) with mapi id 15.20.7046.004; Sun, 19 Nov 2023 16:24:24 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, stephen@networkplumber.org, davem@davemloft.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net,v5, 1/3] hv_netvsc: fix race of netvsc and VF register_netdevice Date: Sun, 19 Nov 2023 08:23:41 -0800 Message-Id: <1700411023-14317-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> References: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0197.namprd03.prod.outlook.com (2603:10b6:303:b8::22) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|BY1PR21MB3893:EE_ X-MS-Office365-Filtering-Correlation-Id: ee0314f5-9e13-4a47-c3be-08dbe91bfe8e X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J56npG98Q4hMp1ptrRv7d3uScEyOHMW7BH2Q9i8iBUbvMcP02dqoPZJuofM8pU8yF8TWM2E6/7o8h6BQjgmUn34Oku7f+FxNeQHSyeTmOzJ9GQh/zSf2eaGP4iLzVuDia4EZiXowxGKsmnbE7KMmiZYs7n3QkAh6sQKd3xK9tzwJyGCzLl0fXWrddWDdVQBC01d4rGtnJKoJk/xe0Z/JViHCwEA7IrMQZ2agxMYrRqpFP/H62qyILn18L1jRWa+N4hnXnsUjVWqeSMrUrd/hla1oJOwK2rS4O7MSaaSRiXwN08Ez4sqQ35VPA5yDUfufDnd5L09vimx43R4oJcOvmpXg0/Bacrv56J3ZTqQJRdBihfUN81ATMOPFtc9fRAztJmZPSv1QYaulATHS2zhfuXdJs/rg/rcyU0CfpWpakAWgEHGrCIaRG+ESYCnfHuNji95M6NUdCaEeOLydTym9lu3CoTLDe1C1xs6+dzJ/hp7IkmLzBNhykL8+ywbeXf5Z3t5PMNSP3yMmMa6cEJkey+0tbxLC0LHxXJDSB3+GYbHaai/9LB94rWHAFnTvaSVXf9Cv/PQYLaAc4jqVpSKblmCKBfzsaf+cxI66S+9il/S1VfLkCz7nCVL/N8KacnE4Gjanw3kU4HihsVIB+jG4gtEtn1iBlixDZtGrdt5Espc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(376002)(366004)(396003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(82960400001)(82950400001)(66899024)(38100700002)(36756003)(38350700005)(6512007)(7846003)(6506007)(6666004)(52116002)(478600001)(2616005)(6486002)(10290500003)(8936002)(66946007)(66556008)(66476007)(5660300002)(316002)(8676002)(7416002)(26005)(4326008)(83380400001)(41300700001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pcAhOqt9VMt9YfkjHxuAz+VG6RgSDQISvRCbAU27TsCZgA3YOskUUUHLgsxofjpmS+EXT5NZSaDuX6Zu8wutktwIJykxf1h/UQTUYArHR8yfybl7+TqOB3iJgi8Ge12fb8ngLKGKH3MF/zUqqufQDSYPPX85pZU9qP0nv7wl72kZLltjaqCC7zjQaaYltweb1OTBo60+p5S9drdBLdSYLa58Ffsp0CIdIMAJN0SJpVElj2W0Mjr0LCfn0vQ3L/MMEdZK90jrtXAYv0h+9yhIx9J3M3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6+ZS6NboL+cnFWHdk0knRcbbrNEtjfobKWFZ4ZpYO7BtawaY966g0HIB1ZqPG67BmgwZHLiVTOmqX78/+f9Hw3tdqLRIennoL4YF/j4AkVPhuNnlnM+QxDqPA+nUEdkQpgGomze6hNk+8Gotk0AiJkewEV2AB888t2Z5Nggx97o7STra5ThPu6rJXN6iv93uYz7TSGQUxzW3wH9fsfHrz7kJWfj/01OY535uCD67G4 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee0314f5-9e13-4a47-c3be-08dbe91bfe8e X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 16:24:24.8585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: x2zZ71AasVqhKaTZSE6HZfjEJklZuCJZGmDgl+pUs09PzmHkSSLqb3ENxePwJiwHl0OrTDdKsXM1oabiOP/wbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR21MB3893 X-Patchwork-Delegate: kuba@kernel.org The rtnl lock also needs to be held before rndis_filter_device_add() which advertises nvsp_2_vsc_capability / sriov bit, and triggers VF NIC offering and registering. If VF NIC finished register_netdev() earlier it may cause name based config failure. To fix this issue, move the call to rtnl_lock() before rndis_filter_device_add(), so VF will be registered later than netvsc / synthetic NIC, and gets a name numbered (ethX) after netvsc. Cc: stable@vger.kernel.org Fixes: e04e7a7bbd4b ("hv_netvsc: Fix a deadlock by getting rtnl lock earlier in netvsc_probe()") Reported-by: Dexuan Cui Signed-off-by: Haiyang Zhang Reviewed-by: Wojciech Drewek Reviewed-by: Simon Horman Reviewed-by: Dexuan Cui --- v3: Divide it into two patches, suggested by Jakub Kicinski. v2: Fix rtnl_unlock() in error handling as found by Wojciech Drewek. --- drivers/net/hyperv/netvsc_drv.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 3ba3c8fb28a5..5e528a76f5f5 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2531,15 +2531,6 @@ static int netvsc_probe(struct hv_device *dev, goto devinfo_failed; } - nvdev = rndis_filter_device_add(dev, device_info); - if (IS_ERR(nvdev)) { - ret = PTR_ERR(nvdev); - netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); - goto rndis_failed; - } - - eth_hw_addr_set(net, device_info->mac_adr); - /* We must get rtnl lock before scheduling nvdev->subchan_work, * otherwise netvsc_subchan_work() can get rtnl lock first and wait * all subchannels to show up, but that may not happen because @@ -2547,9 +2538,23 @@ static int netvsc_probe(struct hv_device *dev, * -> ... -> device_add() -> ... -> __device_attach() can't get * the device lock, so all the subchannels can't be processed -- * finally netvsc_subchan_work() hangs forever. + * + * The rtnl lock also needs to be held before rndis_filter_device_add() + * which advertises nvsp_2_vsc_capability / sriov bit, and triggers + * VF NIC offering and registering. If VF NIC finished register_netdev() + * earlier it may cause name based config failure. */ rtnl_lock(); + nvdev = rndis_filter_device_add(dev, device_info); + if (IS_ERR(nvdev)) { + ret = PTR_ERR(nvdev); + netdev_err(net, "unable to add netvsc device (ret %d)\n", ret); + goto rndis_failed; + } + + eth_hw_addr_set(net, device_info->mac_adr); + if (nvdev->num_chn > 1) schedule_work(&nvdev->subchan_work); @@ -2586,9 +2591,9 @@ static int netvsc_probe(struct hv_device *dev, return 0; register_failed: - rtnl_unlock(); rndis_filter_device_remove(dev, nvdev); rndis_failed: + rtnl_unlock(); netvsc_devinfo_put(device_info); devinfo_failed: free_percpu(net_device_ctx->vf_stats); From patchwork Sun Nov 19 16:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13460486 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="UT5Lvm3Y" Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (mail-centralusazon11020002.outbound.protection.outlook.com [52.101.61.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83A401AA; Sun, 19 Nov 2023 08:24:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OVWZLVoCRupSuYzqmLcWbQ4TEnvPSC/9oEAfMgAuMk7zno2Lpmw6yOTBtgp7V05XPjRhPSVGvcKHtKjZVBl0kH2Un8FXwU3OyP8Q8/FLrCXhUqMkGOXflmWsmNaFMft9V+2D+O7ZI5G7bjdPevCnWTL8Fstr61UpMt+zl3v15XZSBZxw/9kS4wbA1YFItEVDYCHH8WNqXIPkUmHKVUCSXYjwaMSUN3At7dErh5ZYG+DViAE4QltF1WpMvKJWmqvexVU96NYpKkPeZUORebbg64SAF0PVySb4ZVcw8rvc02rzxmDH3WzI4W4H4BnSAQLmJ40wYdEu9oJAbHpTQMHWjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0of2UfaZwNf7YQmNkJmzWnf2upmP22cYVHyP/Kb+l7k=; b=mKh0Jyv1KoReIiIhLsStco3nQ2MRZzPkjVIkx3PvSU+PIA55wRR7bkn5E8qKFYdJqgy639q5ntqAf1LSA5OCXQEk8keDFxkKs7WECxJtujnwpuMLz4nRDtzP/4XGo2S25O0uswJObyjuHRoZ0sx13Svyv5ztAgOvMIVZQfpNlhwsnrsMEWtT6tPqrPSUXEB8f3YBUA7UDz1KxxlbXxJlh2mkBF27ONul/s8oo910oNNb2bDXE8P4EwDfWF5EY2TNFFJaTf79O+2W3Ax0XGLvsJYy/sNz6UyLLHiM4/SYDObFbJVhIUhqDI6zyxUGw+YLajFV1xgGQ/wL65y2qwxoKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0of2UfaZwNf7YQmNkJmzWnf2upmP22cYVHyP/Kb+l7k=; b=UT5Lvm3YbrP3cNKx9DBu7CNoBZYWFFv2X0tNRQYfw7LryA/uq4sUo7ajkWRXLBXNjGx6n3Ih4SAcWo2GqmTL0vpv3ZMNg6whzq46jnukVq2x5sP/AB1gzmGQd+OjnNBqVbd4XH7QBsPSY255vLleA7BxJz+vV/m0MV4rOLXAxBs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by BY1PR21MB3893.namprd21.prod.outlook.com (2603:10b6:a03:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.8; Sun, 19 Nov 2023 16:24:27 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20%3]) with mapi id 15.20.7046.004; Sun, 19 Nov 2023 16:24:27 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, stephen@networkplumber.org, davem@davemloft.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net,v5, 2/3] hv_netvsc: Fix race of register_netdevice_notifier and VF register Date: Sun, 19 Nov 2023 08:23:42 -0800 Message-Id: <1700411023-14317-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> References: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0197.namprd03.prod.outlook.com (2603:10b6:303:b8::22) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|BY1PR21MB3893:EE_ X-MS-Office365-Filtering-Correlation-Id: 82ec2129-7407-4fbc-69d2-08dbe91c0001 X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YnGXBf5AMu3bshXq9AVeN281MSOJSnPDHpjzupTa7vw+ynJ2V2Wa0uuWVxC5Z0CyQegqXo1fOJwwD3Cgustneu+4rvt0J5USvgfIdsmJcZc0H1vGoJDi1v0F1fRpULXZXeh+dCKoTw4YSI/oWukCDgJUFk8u8taen/8pFQHmbFTlO5ig4yLeobeQ6h4FhWUbyAdYO1L+ogpgbI9NGaehgUQRU2ByJEr18r4bydrwngbxqoljxGc22wj0TIAUBBYOeTprNHEpqad3BJVL6cq8DUrKH+u3AGbqTo6X/dJDOEpTQiZURpAdOjQ3iXaU32c62Tu/kUq84hgMAzlvnoZKThh19lQY/4aFQBh4iOyOHxjq9wz0vRS4FCR1G51vhSrWuwWE2Uq3F1lmiJR896rFj2pGFLhy9mpkm5NvZ/aOexvu7RT1Q2+CHz1JshOUzn3MvCKqMdeckaBViIpCXGnIYxKLu+rYA17ydIVZ2bgwKREHJNO+uqaU6pl3EfjkpbEILF96nj4fgPBek/ArmcvX4ovHKHuAlyTEIkBT5ccI9ibmFe5I792J/I9Of/ke2XPVkz5brmh2u/Mu7xT2gndOH6NbECYAuepKWEjsg9Bl6P8nKT/13oumt0SxHK1k3oHtSLISOcbRquuSF7S47lIQAKOnMfDV3AoCr/a3rbJG+5M= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(376002)(366004)(396003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(82960400001)(82950400001)(38100700002)(36756003)(38350700005)(6512007)(7846003)(6506007)(6666004)(52116002)(478600001)(2616005)(6486002)(10290500003)(8936002)(66946007)(66556008)(66476007)(5660300002)(316002)(8676002)(7416002)(26005)(4326008)(83380400001)(41300700001)(2906002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qg7T3LubIo5zVy3duiVfbWBDp1k4WwVcVHpLnGw83L70qu8jZpMNfDGamQQxc1bfbk3LSFMUIlugpJqYtjPGEJZRscylh7N0OKVEqYt6Fq9G2Lbmus53XbauWpxV6guofpa53hQimit62sFkefEej1agcDIGmcP4bz8L2h9z6JO3YeLKsJiz0K6sQisAEr4CXEOcLPY6zDsKTm/oTLeQCrCDcRVJ3whlrlRbQSI4MOVz8KzIbnRIkVPJNBXv1DxydhUXt3oFKPiWvGYDEul5JsWFA6lNQE7DSasLz79CgvsU58Up9lvEwjQNMTJ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kcUq2D6RY1N7y/q2CqgfSaN/l72kalZvh9JNvnC/l0GXICsOWX5ycc6oLg5OvyD+1Of9m/ECmNwojMp4beH2ArzI/q4y1B9H2U/1U8ULEYllFUuAdwcYc6vQszem9Bdvx3CE2gLqekMwu5j8qN5F2xPRAneD9H2jq1sU4yAb5P/9MHcFhy8VFSHcteUejIbyF3SF80ZZF62r7AK X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82ec2129-7407-4fbc-69d2-08dbe91c0001 X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 16:24:27.2553 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9+YC+C+7TdPMcOdkjYvbYk2xvXKCmZF3Imv+SuMawLX40VeIXI6NqEtwiAicfJW8iOems9iSOASJ07J8VNnZfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR21MB3893 X-Patchwork-Delegate: kuba@kernel.org If VF NIC is registered earlier, NETDEV_REGISTER event is replayed, but NETDEV_POST_INIT is not. Move register_netdevice_notifier() earlier, so the call back function is set before probing. Cc: stable@vger.kernel.org Fixes: e04e7a7bbd4b ("hv_netvsc: Fix a deadlock by getting rtnl lock earlier in netvsc_probe()") Reported-by: Dexuan Cui Signed-off-by: Haiyang Zhang Reviewed-by: Wojciech Drewek Reviewed-by: Dexuan Cui --- v5: Use a more idiomatic form for the error path, suggested by Simon Horman. v3: Divide it into two patches, suggested by Jakub Kicinski. v2: Fix rtnl_unlock() in error handling as found by Wojciech Drewek. --- drivers/net/hyperv/netvsc_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 5e528a76f5f5..b7dfd51f09e6 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2793,12 +2793,17 @@ static int __init netvsc_drv_init(void) } netvsc_ring_bytes = ring_size * PAGE_SIZE; + register_netdevice_notifier(&netvsc_netdev_notifier); + ret = vmbus_driver_register(&netvsc_drv); if (ret) - return ret; + goto err_vmbus_reg; - register_netdevice_notifier(&netvsc_netdev_notifier); return 0; + +err_vmbus_reg: + unregister_netdevice_notifier(&netvsc_netdev_notifier); + return ret; } MODULE_LICENSE("GPL"); From patchwork Sun Nov 19 16:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13460487 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="Ussgyxys" Received: from DM6FTOPR00CU001.outbound.protection.outlook.com (mail-centralusazon11020003.outbound.protection.outlook.com [52.101.61.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 969B3D65; Sun, 19 Nov 2023 08:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CftCayIFtNMVWheRGIsF/GEXCR0NbSOBu1imJF2U5RAzxPmqguGMRbObyU5UzUhUGiO193NQFhCssv2rN9hqgARc7MMMUdA8Ey+II7Ld2Tq+yDcAk+Ha6O39knA5/p3K0xD8DAHD/Otom0NLdvH3L5se7unR7Dq4gKlvhy0Yqioo93HGU80oeBTRe7R20d2hazBIUjn/F2HBB2jBA/Ez8JX7LarYu6VCxU59csc0fVfAE6fmGakpq75Px9Qh3iHqGPUWWK9hbd92vpqwKIfd07OI+CMqA5uCXr15qUD9F/0//pcjX05RNIJfL5Pf3Q2XQSsvh7URNX6R2Zae/lrvNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H36dzqXp77Rv9GD8GbYy9bgWqPlS9/c9lrb4Eap2q6k=; b=Os3dcVhUfV8Lz3CLM8QMpsLkAzS2vWd4ToRt2j99/NBhnqaKQ1Axhij19qE/vdOz/b2Gpkzfcpe/tHGRTzSUWiaJ/32fs1HohY1o9XHNwIJZTAtFYbaCAgqZ4a3toIUiDozuhYQ/7rBZ082o3y+0XqBVt2Q3dfnSLsxHKvD9gLLICaZ4v1brasmnjTdwp6FiSkvOIVzoMKOBIEXSJ5bmhIvw6NZhOAXEI1Y5+PpieVRiPnC3MI40WiUn/3PRebFU8QJK7t27d3a8Q0tV4s3ldbefR+94Xna8R3yV9irr7X0yMIHBbcxE/Eu5GCcH3yqLcdtT0rO4XuI7n5rUoS0FJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H36dzqXp77Rv9GD8GbYy9bgWqPlS9/c9lrb4Eap2q6k=; b=UssgyxysRV2r0DB5n2/Vn4MHtZtqCmv4AtsUlGC9eYs+vqUk3Obs+qVIQ1c4npKS3UoZRBkajPR15MngKohKRFR8UAJBUnPSavlpfroXEYFS1uWJMwlxF+R+xcGEtUeF/Lci5mvkdDrmw8Ir7nLIIuFaZgDeVNbQhzsU479znko= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by BY1PR21MB3893.namprd21.prod.outlook.com (2603:10b6:a03:52d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.8; Sun, 19 Nov 2023 16:24:38 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::d819:9f58:df81:2d20%3]) with mapi id 15.20.7046.004; Sun, 19 Nov 2023 16:24:38 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, kys@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, stephen@networkplumber.org, davem@davemloft.net, linux-kernel@vger.kernel.org, Long Li , stable@vger.kernel.org Subject: [PATCH net,v5, 3/3] hv_netvsc: Mark VF as slave before exposing it to user-mode Date: Sun, 19 Nov 2023 08:23:43 -0800 Message-Id: <1700411023-14317-4-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> References: <1700411023-14317-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0197.namprd03.prod.outlook.com (2603:10b6:303:b8::22) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|BY1PR21MB3893:EE_ X-MS-Office365-Filtering-Correlation-Id: 052a199d-fd64-4268-ba8f-08dbe91c06d6 X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wn6dZBPPh+Ya/TKmAfr7XArVCTZkPLf6dGK1uQKUZ/SnzUd48C2NrYCzKqytMhfrgXV8WEdawigX9SUFuIllAYjRsI2hWV7hyQd35K/KGi3SYUM6fju4lG63JYPdgLnLgf1vzRSPKGKIIpOEupf081wwUkutCLGp2k/NcOFxhapD9kpI++TQJOt6+gBreDviRt/ECWk3NtzDv7kDCrQXMOG7q2zShmYEz0bvgcm98COegvIQLaULUgVuoVGyBd+oFnW2NpJreNvd2UxqAxj0ngub5yd7KE10bM9NCKAWmXGEReYzhYDgmDfOgQauH5IZkdX9LDVS9aRZc6GVGh0dm/nEUzEvfFYdyn7f3HAOaCBb/Ib5Y4AmOG5JAsCoIwn7hfM/TBXR0stzhT4vYmjao7s4U3jyOUlG2iE0wW72lMNzAMXACRf7JtGHW1G03wXRAew3qRdQJhGM35IRqRi+74zAdTE2FUkWMxKKJJQ75SXRgJ7IcMdf7zUg4IzFXP1t+MErdZ9Cw9EIzmJgQaM2lzGc8mvyTXWJohbtylnrOKIyqymTyX2k80v2SE8/1jR8Y0hMYLaZ6V9T+KYeBEor8EVWRUS3hmvx2lQGA/vDkI3qp3I3dgOWtFFwl5TK73GYkGtgQsNz1Ap9KftyqTQyozGySeuap+OfUxlfrpDK4nY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(376002)(366004)(396003)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(82960400001)(82950400001)(38100700002)(36756003)(38350700005)(6512007)(7846003)(6506007)(6666004)(52116002)(478600001)(2616005)(6486002)(10290500003)(8936002)(66946007)(66556008)(66476007)(5660300002)(316002)(8676002)(7416002)(26005)(4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torhZd5/cNDTCgHIrqKear0PZT+6Rsl3tjatI7MQD+sJL5x7Ywi5INOBkUe7UgHrU7AmZcgqx/K6dFsF7n2JV1J76WKnSQ5u4KNDGFyr2vlJC8hhNfd5GIHCHQR63IMamtehzRT3yHYggtfgU6CCHeS40L7xMKctbXfzI8yzi8puE81oyf9lQ2AJlLSQSP/zOGYYyRjcLBNeQMaClWRtOLA3I3KOLL9rnmwGMBhC7ISzP7ndUGzz5v9tlTOZou6r5tQ47y0q+Yi85iAr70Bm8HWLrDlU1QaRUZWfZ/vBSeoo7cGhWZkp4Eld24mNhrYry/OcleC+vwJkOiWSfycjfAFzf1e0HUDdePMNV6LKwvrh51LX1lTVnypqefeEpAny2QS/AOp2vtngRfmjtI2iXv237S1gI3nyQdUbrD+AnZ/jspLkLRUCYrCfSw8s20loYVcDLHoI1MyLIQU3QZfdV/Gn1FP3vaEhWii9hfeL0r1ci4Ayn5XQ3CeqC6yE4oqddvVOW39Psf+SzNu1rrXbionwxI/wT7yupmJEaNhh1CG8KecC/jDdsfoV52lt/PMyg7SvcJryMJwi2ms7yXQcglwWQuDHjGuxAWWEXoOAoiaGYfUT X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 052a199d-fd64-4268-ba8f-08dbe91c06d6 X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Nov 2023 16:24:38.7226 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 42R7m6rlyAlBs2jBIrV4Ie3AcfjTOpEqnZ/naK1dhePvnOP32DL5+Z392+TYRj8S6qmVz3dVrC5quW/CHJnpbw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR21MB3893 X-Patchwork-Delegate: kuba@kernel.org From: Long Li When a VF is being exposed form the kernel, it should be marked as "slave" before exposing to the user-mode. The VF is not usable without netvsc running as master. The user-mode should never see a VF without the "slave" flag. This commit moves the code of setting the slave flag to the time before VF is exposed to user-mode. Cc: stable@vger.kernel.org Fixes: 0c195567a8f6 ("netvsc: transparent VF management") Signed-off-by: Long Li Signed-off-by: Haiyang Zhang Acked-by: Stephen Hemminger Acked-by: Dexuan Cui --- v5: Change function name netvsc_prepare_slave() to netvsc_prepare_bonding(). v4: Add comments in get_netvsc_byslot() explaining the need to check dev_addr v2: Use a new function to handle NETDEV_POST_INIT. --- drivers/net/hyperv/netvsc_drv.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index b7dfd51f09e6..706ea5263e87 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2206,9 +2206,6 @@ static int netvsc_vf_join(struct net_device *vf_netdev, goto upper_link_failed; } - /* set slave flag before open to prevent IPv6 addrconf */ - vf_netdev->flags |= IFF_SLAVE; - schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT); call_netdevice_notifiers(NETDEV_JOIN, vf_netdev); @@ -2315,16 +2312,18 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) } - /* Fallback path to check synthetic vf with - * help of mac addr + /* Fallback path to check synthetic vf with help of mac addr. + * Because this function can be called before vf_netdev is + * initialized (NETDEV_POST_INIT) when its perm_addr has not been copied + * from dev_addr, also try to match to its dev_addr. + * Note: On Hyper-V and Azure, it's not possible to set a MAC address + * on a VF that matches to the MAC of a unrelated NETVSC device. */ list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) { ndev = hv_get_drvdata(ndev_ctx->device_ctx); - if (ether_addr_equal(vf_netdev->perm_addr, ndev->perm_addr)) { - netdev_notice(vf_netdev, - "falling back to mac addr based matching\n"); + if (ether_addr_equal(vf_netdev->perm_addr, ndev->perm_addr) || + ether_addr_equal(vf_netdev->dev_addr, ndev->perm_addr)) return ndev; - } } netdev_notice(vf_netdev, @@ -2332,6 +2331,19 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) return NULL; } +static int netvsc_prepare_bonding(struct net_device *vf_netdev) +{ + struct net_device *ndev; + + ndev = get_netvsc_byslot(vf_netdev); + if (!ndev) + return NOTIFY_DONE; + + /* set slave flag before open to prevent IPv6 addrconf */ + vf_netdev->flags |= IFF_SLAVE; + return NOTIFY_DONE; +} + static int netvsc_register_vf(struct net_device *vf_netdev) { struct net_device_context *net_device_ctx; @@ -2758,6 +2770,8 @@ static int netvsc_netdev_event(struct notifier_block *this, return NOTIFY_DONE; switch (event) { + case NETDEV_POST_INIT: + return netvsc_prepare_bonding(event_dev); case NETDEV_REGISTER: return netvsc_register_vf(event_dev); case NETDEV_UNREGISTER: