Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp137634imp; Tue, 19 Feb 2019 20:09:48 -0800 (PST) X-Google-Smtp-Source: AHgI3IYcDy8qCLRiYFruUBn1wmCIPY0J5rKrab3bDkUxyQ+1TMG+d6Y5AIyxChi/4hIWJsP4aAJ0 X-Received: by 2002:a17:902:7007:: with SMTP id y7mr32569601plk.167.1550635788360; Tue, 19 Feb 2019 20:09:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550635788; cv=none; d=google.com; s=arc-20160816; b=flTA5sM+xQMh6hkypBviCwiH4zrqqZHYaYruAOK43KsQ8/2UjP3sVQxlNq+LFYwIAW FEFWaKt7Nxi1hV61qTjrpU7+24uxjRlIfL/THSm2FDuetwaegR5lJkgBiElCWZzoY5Hj yxXYehXzDeSIMqr3Y+DnuEmO62u2mECHmkD2m++R6CI0FoU/+Adss3wuG4RlMctaIDou +T7UpDhWeF5ypact+ySEoRqjrhZiPmsGAJ4ZsePaFT3FbZp+kRBAoKp627gu3HV8pXT/ oZ/CAu3AbHdeFuyRYoebfT8RzJgac5VltwGYayzmvAv0ZX07TgHw7DHBI5ST83y80IJA HQYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jrq0vtH0QTYMuPVHkZU/Hm3vLoDV6p5bboaCxjtmhVY=; b=BGzWwOR5w5GEh2aWBluLpJ2wg89K54U5yLxdzWLUikTGs0StpNBZlzjKvco80tVYYL KY4Wp9z1OXPCJ+mO6LHntV6/s+fINmuubvdzIaFyw5ZY51jSMTDWz8DcI+1NX/U/nUXe 9zhUut22V39yVRKP7mbg/rxPgnxIBXkl+RJsi6+WK5f0dOsrRkr8sFq//noGd2zWuDiO jHcfUiQ8o6ASEEzN0YattfYC6WnfM5Op6uEKwyryvFCd4/8Xdv0jnf/OOeZO5A52nbGf eCK7bu9Fp+i/cAS2be0Tk1R1YEvY7TGYhoLtzXL+ZIM1wZFzh4rddvrneII/HgntJMSl bt1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=uurRNFsC; 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 o11si8384426pls.378.2019.02.19.20.09.33; Tue, 19 Feb 2019 20:09:48 -0800 (PST) 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=@joelfernandes.org header.s=google header.b=uurRNFsC; 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 S1730330AbfBTEJG (ORCPT + 99 others); Tue, 19 Feb 2019 23:09:06 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37341 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728691AbfBTEJE (ORCPT ); Tue, 19 Feb 2019 23:09:04 -0500 Received: by mail-qk1-f194.google.com with SMTP id m9so1140808qkl.4 for ; Tue, 19 Feb 2019 20:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jrq0vtH0QTYMuPVHkZU/Hm3vLoDV6p5bboaCxjtmhVY=; b=uurRNFsCYX6PMRTytiTuGcwrMTTZOTBDjQ0SUTATr2KRFxnBwKKjEwnlSXek2YTNry X71aG3hwnTf83MjrTNF3rf4eGy1EbtFJmvot9TUOIzgKpamBMIJRhF6TNppZ1oyFumGZ jNkX4Yih63iakKtmAiXSCCC/QvAhMeUBBSmJw= 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:mime-version:content-transfer-encoding; bh=jrq0vtH0QTYMuPVHkZU/Hm3vLoDV6p5bboaCxjtmhVY=; b=qfS2pNjzW3hFKj2Ms3dgL2K0qBoJfHtklhiHn5+mX5QfK5M34EcFNpDLDE5HW5Q/FJ 79GSXTOc8h1yZGMATwJ1BIe4dzbh2CF4zCWfiVyQzPXK8v9XZBZTQ4QI+7+9qZ3J+TyD VD9J6pQey+u74dd7sA9xEfKUTMtxMcDQfveDS74jnx7YVhK2i13qVk342+TGSVbp4EIy LTKDVg3Tr2hbVzyLe9d6vF78PHCFQtOxq/99/CpwuqYG1UcwmQTUvq5wfxN9SAuGTv/K rG5q487bh4YVPTun9iFMaKxmyCr3HpC4tzgR+rDxHxbkDVVNj8egu0rmMEEaEScT7cOV +SaA== X-Gm-Message-State: AHQUAuZQxTDA1vD/fLaU8o7iQ0Vfobih4FZsOPJ9Y7tgVwuRn2ntwqCW HTw/sYrLzMSbjmC3WWKx4mQFSH8vgLU= X-Received: by 2002:ac8:554d:: with SMTP id o13mr25775337qtr.105.1550635743082; Tue, 19 Feb 2019 20:09:03 -0800 (PST) Received: from joelaf.cam.corp.google.com ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id s19sm2024593qth.80.2019.02.19.20.09.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 20:09:02 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org, rcu@vger.kernel.org Cc: Joel Fernandes , paulmck@linux.ibm.com Subject: [RFC 1/5] net: rtnetlink: Fix incorrect RCU API usage Date: Tue, 19 Feb 2019 23:08:23 -0500 Message-Id: <20190220040827.136184-2-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog In-Reply-To: <20190220040827.136184-1-joel@joelfernandes.org> References: <20190220040827.136184-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joel Fernandes rtnl_register_internal() and rtnl_unregister_all tries to directly dereference an RCU protected pointed outside RCU read side section. While this is Ok to do since a lock is held, let us use the correct API to avoid programmer bugs in the future. This also fixes sparse warnings arising from not using RCU API. net/core/rtnetlink.c:332:13: warning: incorrect type in assignment (different address spaces) net/core/rtnetlink.c:332:13: expected struct rtnl_link **tab net/core/rtnetlink.c:332:13: got struct rtnl_link *[noderef] * Signed-off-by: Joel Fernandes --- net/core/rtnetlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 5ea1bed08ede..98be4b4818a9 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -188,7 +188,7 @@ static int rtnl_register_internal(struct module *owner, msgindex = rtm_msgindex(msgtype); rtnl_lock(); - tab = rtnl_msg_handlers[protocol]; + tab = rtnl_dereference(rtnl_msg_handlers[protocol]); if (tab == NULL) { tab = kcalloc(RTM_NR_MSGTYPES, sizeof(void *), GFP_KERNEL); if (!tab) @@ -329,7 +329,7 @@ void rtnl_unregister_all(int protocol) BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX); rtnl_lock(); - tab = rtnl_msg_handlers[protocol]; + tab = rtnl_dereference(rtnl_msg_handlers[protocol]); if (!tab) { rtnl_unlock(); return; -- 2.21.0.rc0.258.g878e2cd30e-goog