Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2328365imm; Mon, 28 May 2018 06:09:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ546kAz2Nv3RA5mOmT61BwXQ3CCyDDzZQxM/J3sU4k7sgqyaG930xR3z6hImQW0A5nS63Q X-Received: by 2002:a17:902:2966:: with SMTP id g93-v6mr1786378plb.250.1527512960850; Mon, 28 May 2018 06:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527512960; cv=none; d=google.com; s=arc-20160816; b=ScWPsg/QqMKrSx0lPZS0ni8c/hyKDtwEGygN7Mkl38DsCqS8j9IMFdz8Omb9TqN2S2 466C0QPnetxIGcHT0mOXTxZLIFIXiXNCvYQjgVOxRtF71YBmJRmuSYNYhJWul7ySqQ2r QYukjyDeAME7Do97vLQoVX8riNEVRkfNXD4pwv5ZpfHKm5hJCHoKFCK3hf/NnAnxEsP9 yuu7KyQZYQBWULNXsDWnPyJMyEz8BHBg6pEMWVp+emYcj6D5wLzFcvH7m1ZKqBgIw1+l DUyTK9pOBlMzEvevj0qEkr27+rWLYP2Volk0wMD6fTgzCzVciro2mTXp9wtoOtraPE41 uw2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=DZNIyEugCMIi0O4xWQ8jKoDEk9dJx31PJRlqVNffNsE=; b=wwbT1dyQxxX5DjfbSrvaVbKFp+rt4BjxuQGD+uhI73PzFhtgBzj36bBIlni+hEowO+ uRBseURz+OWE7iewRWTAjrY0lPHAfYO1fSJjq/oOYPwjSsp2VqueHsSmQABAzTtYUa2N VTPwxsz2bkvJ/WeFByVy7U8nDfqQg2QYUDXo44HxEMUPDkR4MrOfEGZD4LkyaKkeqGLu GMObuqncWq/YftxM/xp5iMmkLohBb9wNcnmfoXqOEyVyrInKn4DCSetsFc7JdJVIwaK9 tDgxkpcR4YKRRPayferVbM0Jcl4m2Bj9ZTTWJAcmHhHDH/BJzQL7FL/vHv2IJleJI7+c 4u4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2L/cEj0n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s184-v6si5577872pgb.172.2018.05.28.06.09.06; Mon, 28 May 2018 06:09:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2L/cEj0n; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163887AbeE1Kvw (ORCPT + 99 others); Mon, 28 May 2018 06:51:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:41170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163652AbeE1Kvs (ORCPT ); Mon, 28 May 2018 06:51:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5797B20660; Mon, 28 May 2018 10:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504707; bh=9DNRg2DGNZGA7Wqjp3g8ftsY4GIew1aChcF05118lPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2L/cEj0ncKxH7xLh6eUTc8YXWeLheCVQ4ZBQU//Fwg6r5MtbpjSLkXd7uNSs/Xs4x DQ+JxabEz8u5E7/QEEV9ci6h2aAFQUVgd0C8LjzNfLkjKJkPLRzjcxPsG2T78RZeoC WjSprgUrj2WhvejlDPtOAmjan2v4YJ+gPCzWngIQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Hemminger , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 235/496] hv_netvsc: fix locking for rx_mode Date: Mon, 28 May 2018 12:00:20 +0200 Message-Id: <20180528100329.810379683@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stephen Hemminger [ Upstream commit 35a57b7fef136fa3d5b735ba773f191b95110fa0 ] The rx_mode operation handler is different than other callbacks in that is not always called with rtnl held. Therefore use RCU to ensure that references are valid. Fixes: bee9d41b37ea ("hv_netvsc: propagate rx filters to VF") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/hyperv/netvsc_drv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -89,15 +89,20 @@ static void netvsc_change_rx_flags(struc static void netvsc_set_rx_mode(struct net_device *net) { struct net_device_context *ndev_ctx = netdev_priv(net); - struct net_device *vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); - struct netvsc_device *nvdev = rtnl_dereference(ndev_ctx->nvdev); + struct net_device *vf_netdev; + struct netvsc_device *nvdev; + rcu_read_lock(); + vf_netdev = rcu_dereference(ndev_ctx->vf_netdev); if (vf_netdev) { dev_uc_sync(vf_netdev, net); dev_mc_sync(vf_netdev, net); } - rndis_filter_update(nvdev); + nvdev = rcu_dereference(ndev_ctx->nvdev); + if (nvdev) + rndis_filter_update(nvdev); + rcu_read_unlock(); } static int netvsc_open(struct net_device *net)