From patchwork Mon Nov 18 09:09:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 179584 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2602283ilf; Mon, 18 Nov 2019 01:09:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzZ65kVLK5T0LW95Kef7L4HAMoVXeIOaz0XxMRVnKVk1bQcSXq/SIf2Z/5CnenCUL8K5v2W X-Received: by 2002:a17:906:7691:: with SMTP id o17mr25076145ejm.323.1574068182955; Mon, 18 Nov 2019 01:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574068182; cv=none; d=google.com; s=arc-20160816; b=Etr2+dQd8Q1lDN6dnSKFDfcZQTJ/1cueM3XZR58otkmou7PhfQ2qh3Eb9LmY6w2s9k p2JjEl4UyqGxSFWCrrn/6EoT15Dak8ZyWulcoi22Ipb/bVqI2T7hm+OMrHnbOapFhwBG lfLEMHhNZdUjnFmHeg/s6b3bg8fxTXfi2Pd7JrqpbsswEHX45Wldp2zPmN0UqAecuyAM SrmL1g1+qR64pEAJuTuDUDR1vdHrfkE62q9+omxsa1YnBo3wMDSoPTPoxkgCR6lUjeO0 8jOTFsniBkg9IS5F+ohWysHGCo47/KZtpFDed6ik2vxokPJkSHNqSBtz5m4angX3AE1U J9ow== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=vRHarKxs+FXQC17mDhZjcIM/UrEIpgau+60o1VUlLBU=; b=qDj75tcGIkPRXK9BtrXsCmIb7xISXzvndVn5yEJH+QtqSrH/+YJVfrV2OnnbcVEzbp pd37ooTjyIjvxXIYS4f4Dq/X4lCKsGochMkO7OFDJGrzW0vC7nR6Cr8zAq1EdTqAMWmY Cwo4BK7w4zO39M5OIx8ei+wpQQiSnLwnFBcuOlcCvGcc/yoqMLd39TY6UVqYYXdSIY05 6SBW+jdescZMpul+9Y2H9+x+gCa9LjJp0CG45GRyTEbuiWOWbAqp//br0ry/iAWqajaU fJpjesL0GfF+LOsfWn9Hoos5L0VutP3Ov2HrmoElSPLMToikZ6LdIGxvRgr8Bi6yowLD 3Aew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iS8KFNLd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gz9si10909836ejb.238.2019.11.18.01.09.42; Mon, 18 Nov 2019 01:09:42 -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=@linaro.org header.s=google header.b=iS8KFNLd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726705AbfKRJJj (ORCPT + 26 others); Mon, 18 Nov 2019 04:09:39 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34050 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbfKRJJj (ORCPT ); Mon, 18 Nov 2019 04:09:39 -0500 Received: by mail-lf1-f68.google.com with SMTP id l28so3671207lfj.1 for ; Mon, 18 Nov 2019 01:09:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vRHarKxs+FXQC17mDhZjcIM/UrEIpgau+60o1VUlLBU=; b=iS8KFNLdFLqOPrD6V35b7GfQj7gpMOzvVLNiAW93HgzmFuCocGe86U9tQYNhCtGH9/ F+TqzaLdZyguwYLCf9PWnDeTQSehf9n/6irOMCHTjflBh4ewrMY9tvsUUQi667HjVvBj qsn6lw5EKap4TVlakLfnu9RWrYaWfH/ttogmmSmZerWzyIjIReYKU9FA/SocSUeORWsN dg51gG/X4xKZ+s1vRvnbBS+zx/5+df70kxZHFeyCBGnBZuHmasyIpzCflCQKRLyRcC+3 rn0GA2jEV78MMCPZJuEBXII31EOjOH7eAlcshQaU5t0QTFxPwAev0MZ4NnfvB0Y3hX3d ydJQ== 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:mime-version :content-transfer-encoding; bh=vRHarKxs+FXQC17mDhZjcIM/UrEIpgau+60o1VUlLBU=; b=SQZce5yW7+AXryD1TKwYNDK2HnqdJ+EZ51KbUYi+JyEKk/3wZt07gN1g4wbjhilT2V 3MIzTGKtB2X17L715UaVFsOydiMNZyktjfNl3GJ3JdFUN8Ps3z9bTXwJQKURmpwrUiim Nwy1fhfBrFqlHEzzRPF8Jr84eG7G54wmpMbVwXIwpHmqJmob65Lb8vrbfftacPOEzlRG /34eepUelThsIfETmRJqJuKe85FjjDmE03oNU11yLR0vlhaLSBcw8gcr/sh60W7m0tnY uVD+y7FcrRwynq4JClIMyT/5wXGjyOFuYmqZv/dnK5eChhRRM0sB666JKWcqCI+YkJP7 7N3A== X-Gm-Message-State: APjAAAU2Mm/gHv5sGqOVpH5XzalOxsPKA5kA43u0u45PMa5LeL7qKokM MYeMs0SUL2e+PJzT5iaiXBFGOA== X-Received: by 2002:a19:6d19:: with SMTP id i25mr19733291lfc.178.1574068176629; Mon, 18 Nov 2019 01:09:36 -0800 (PST) Received: from localhost (c-413e70d5.07-21-73746f28.bbcust.telenor.se. [213.112.62.65]) by smtp.gmail.com with ESMTPSA id e10sm7997635ljp.23.2019.11.18.01.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 01:09:35 -0800 (PST) From: Anders Roxell To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org Cc: paulmck@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell Subject: [PATCH] net: ipmr: fix suspicious RCU warning Date: Mon, 18 Nov 2019 10:09:25 +0100 Message-Id: <20191118090925.2474-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When booting an arm64 allmodconfig kernel on linux-next (tag next-20191115). The following "suspicious RCU usage" warning shows up. This bug seems to have been introduced by commit f0ad0860d01e ("ipv4: ipmr: support multiple tables") in 2010, but the warning was added only in this past year by commit 28875945ba98 ("rcu: Add support for consolidated-RCU reader checking"). [ 32.496021][ T1] ============================= [ 32.497616][ T1] WARNING: suspicious RCU usage [ 32.499614][ T1] 5.4.0-rc6-next-20191108-00003-gf74bac957b5c-dirty #2 Not tainted [ 32.502018][ T1] ----------------------------- [ 32.503976][ T1] net/ipv4/ipmr.c:136 RCU-list traversed in non-reader section!! [ 32.506746][ T1] [ 32.506746][ T1] other info that might help us debug this: [ 32.506746][ T1] [ 32.509794][ T1] [ 32.509794][ T1] rcu_scheduler_active = 2, debug_locks = 1 [ 32.512661][ T1] 1 lock held by swapper/0/1: [ 32.514169][ T1] #0: ffffa000150dd678 (pernet_ops_rwsem){+.+.}, at: register_pernet_subsys+0x24/0x50 [ 32.517621][ T1] [ 32.517621][ T1] stack backtrace: [ 32.519930][ T1] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.0-rc6-next-20191108-00003-gf74bac957b5c-dirty #2 [ 32.523063][ T1] Hardware name: linux,dummy-virt (DT) [ 32.524787][ T1] Call trace: [ 32.525946][ T1] dump_backtrace+0x0/0x2d0 [ 32.527433][ T1] show_stack+0x20/0x30 [ 32.528811][ T1] dump_stack+0x204/0x2ac [ 32.530258][ T1] lockdep_rcu_suspicious+0xf4/0x108 [ 32.531993][ T1] ipmr_get_table+0xc8/0x170 [ 32.533496][ T1] ipmr_new_table+0x48/0xa0 [ 32.535002][ T1] ipmr_net_init+0xe8/0x258 [ 32.536465][ T1] ops_init+0x280/0x2d8 [ 32.537876][ T1] register_pernet_operations+0x210/0x420 [ 32.539707][ T1] register_pernet_subsys+0x30/0x50 [ 32.541372][ T1] ip_mr_init+0x54/0x180 [ 32.542785][ T1] inet_init+0x25c/0x3e8 [ 32.544186][ T1] do_one_initcall+0x4c0/0xad8 [ 32.545757][ T1] kernel_init_freeable+0x3e0/0x500 [ 32.547443][ T1] kernel_init+0x14/0x1f0 [ 32.548875][ T1] ret_from_fork+0x10/0x18 This commit therefore introduces a lockdep-specific variable that maintains initialization state. It then passes this variable along with the return value of lockdep_rtnl_is_held() to list_for_each_entry_rcu() in order to correctly check for proper RCU/locking/initialization state. Suggested-by: Paul E. McKenney Reviewed-by: Paul E. McKenney Signed-off-by: Anders Roxell --- net/ipv4/ipmr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 6e68def66822..93007c429dae 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -108,9 +108,18 @@ static void igmpmsg_netlink_event(struct mr_table *mrt, struct sk_buff *pkt); static void mroute_clean_tables(struct mr_table *mrt, int flags); static void ipmr_expire_process(struct timer_list *t); +#ifdef CONFIG_PROVE_LOCKING +int ip_mr_initialized; +void ip_mr_now_initialized(void) { ip_mr_initialized = 1; } +#else +const int ip_mr_initialized = 1; +void ip_mr_now_initialized(void) { } +#endif + #ifdef CONFIG_IP_MROUTE_MULTIPLE_TABLES #define ipmr_for_each_table(mrt, net) \ - list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list) + list_for_each_entry_rcu(mrt, &net->ipv4.mr_tables, list, \ + (lockdep_rtnl_is_held() || !ip_mr_initialized)) static struct mr_table *ipmr_mr_table_iter(struct net *net, struct mr_table *mrt) @@ -3160,6 +3169,8 @@ int __init ip_mr_init(void) rtnl_register(RTNL_FAMILY_IPMR, RTM_GETLINK, NULL, ipmr_rtm_dumplink, 0); + + ip_mr_now_initialized(); return 0; #ifdef CONFIG_IP_PIMSM_V2