From patchwork Fri Aug 4 14:54:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 797840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="SJaQvv5l"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xP92W1dttz9sxR; Sat, 5 Aug 2017 00:55:15 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dde0O-0007LV-E9; Fri, 04 Aug 2017 14:55:12 +0000 Received: from mail-qt0-f180.google.com ([209.85.216.180]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dde0H-0007HL-2k for kernel-team@lists.ubuntu.com; Fri, 04 Aug 2017 14:55:05 +0000 Received: by mail-qt0-f180.google.com with SMTP id p3so10501137qtg.2 for ; Fri, 04 Aug 2017 07:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IQJvVbPth+cOgAnIU8zTpJbJpSzB1Z5Y1QtYlVbYc3U=; b=SJaQvv5ldsdz549Ei1PBCS/8Q0F7B6b84NtdpSh86iIhCpJ/5runuXbGwFWe5847HP i6d30x5o1G700UzMgFLPq1+VSGvEbo4ZmMCFH2ymUjDsWKou/PY6S98pgFEW9H5BLZsw Bb5aX2vWXE/QOTdYJ3B2Q3S5eWsJoEFwXNbBSr5p8NELHCw4TdmUDEWFgMFhGb+cFJNH FDs2U3ccKJw1YsOR9dgAeZWZU9vvQ2B1UKxluVwgLrB+tJZ3I4MVVJHungRphC+919gJ m3p8NgVKDfs3ssm0je9aMRNe3LgBhp89xbkiRuVIg8eonZYhPmdow+/S3vBT5l50wTsI 8gdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IQJvVbPth+cOgAnIU8zTpJbJpSzB1Z5Y1QtYlVbYc3U=; b=i+PkJxbzjA9OKFlatWG8MR56vxKtxqwz7Fu0658VEmAA5A1QN6AucxfF4C/TYCG3Tn OYOJetV7yUHFW71yz13VAzMsCTLOeUSoydZ+/ejrELDwooOoi6WVCpjB6dxh2ZA2HoCB S3AQZbKIGX2hGZRFjMw2OFlSdfcJgtxi7cAjErJ4S5OyF2PuMxyCrUhw2GnspUTZJpxk U9Mi0Exfb+wRNFqGyg0o+nTR4j+hmQHqa99kjWSq8jPeca3oYPjJ5ONFpOzZL5v313CM GN3jkIu3RTAepMjFWk7XWuDb8X8aee/b53FD+ZHQfWV43EU8oFFecZIKQEbXvlYcXPvW Wnjg== X-Gm-Message-State: AHYfb5gF91gM1D5YHOriZE09koak+4UN/9gJ3PcfCEVGHgoZTucINtMT 0e+ypPxJ250c7Az0cWA= X-Received: by 10.237.36.107 with SMTP id s40mr3774753qtc.137.1501858503794; Fri, 04 Aug 2017 07:55:03 -0700 (PDT) Received: from localhost.localdomain ([191.8.84.147]) by smtp.gmail.com with ESMTPSA id z47sm1194750qth.87.2017.08.04.07.55.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Aug 2017 07:55:02 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure][PATCH v1 5/9] UBUNTU: SAUCE: netvsc: add some rtnl_dereference annotations Date: Fri, 4 Aug 2017 11:54:40 -0300 Message-Id: <1501858484-28849-6-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> References: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> Cc: Josh Poulson , Stephen Hemminger X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: stephen hemminger BugLink: http://bugs.launchpad.net/bugs/1708469 In a couple places RTNL is held, and the netvsc_device pointer is acquired without annotation. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (cherry picked from net-next commit 79e8cbe7a789a0863cc6cd874872b4dd63ec5947) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/netvsc.c | 5 +++-- drivers/net/hyperv/netvsc_drv.c | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index de3aa1cb2611..ca7d07f8e4f1 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -44,7 +44,7 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf) { struct net_device_context *net_device_ctx = netdev_priv(ndev); struct hv_device *dev = net_device_ctx->device_ctx; - struct netvsc_device *nv_dev = net_device_ctx->nvdev; + struct netvsc_device *nv_dev = rtnl_dereference(net_device_ctx->nvdev); struct nvsp_message *init_pkt = &nv_dev->channel_init_pkt; memset(init_pkt, 0, sizeof(struct nvsp_message)); @@ -569,7 +569,8 @@ void netvsc_device_remove(struct hv_device *device) { struct net_device *ndev = hv_get_drvdata(device); struct net_device_context *net_device_ctx = netdev_priv(ndev); - struct netvsc_device *net_device = net_device_ctx->nvdev; + struct netvsc_device *net_device + = rtnl_dereference(net_device_ctx->nvdev); int i; netvsc_disconnect_vsp(device); diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index c506033c0c1b..0c79a73bf37a 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -77,7 +77,7 @@ static void netvsc_set_multicast_list(struct net_device *net) static int netvsc_open(struct net_device *net) { struct net_device_context *ndev_ctx = netdev_priv(net); - struct netvsc_device *nvdev = ndev_ctx->nvdev; + struct netvsc_device *nvdev = rtnl_dereference(ndev_ctx->nvdev); struct rndis_device *rdev; int ret = 0; @@ -1396,7 +1396,7 @@ static struct net_device *get_netvsc_byref(struct net_device *vf_netdev) continue; /* not a netvsc device */ net_device_ctx = netdev_priv(dev); - if (net_device_ctx->nvdev == NULL) + if (!rtnl_dereference(net_device_ctx->nvdev)) continue; /* device is removed */ if (rtnl_dereference(net_device_ctx->vf_netdev) == vf_netdev) @@ -1625,7 +1625,8 @@ static int netvsc_remove(struct hv_device *dev) * removed. Also blocks mtu and channel changes. */ rtnl_lock(); - rndis_filter_device_remove(dev, ndev_ctx->nvdev); + rndis_filter_device_remove(dev, + rtnl_dereference(ndev_ctx->nvdev)); rtnl_unlock(); unregister_netdev(net);