From patchwork Wed Nov 20 15:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 179856 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2248918ilf; Wed, 20 Nov 2019 07:23:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzZ3cHZYgsC+/wpOiNVwdgXZ72XBICN0bp1KkiTJhn0y7spuXVmI11SEDi0Aju4iVcLyoOU X-Received: by 2002:a2e:9802:: with SMTP id a2mr3340811ljj.254.1574263391489; Wed, 20 Nov 2019 07:23:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574263391; cv=none; d=google.com; s=arc-20160816; b=GCZsUE1uix0jlm1VMRsTXo0n1ctH/TzwK9/o1mIqXcdKNd3jhMeAW4q/CTfy/3NQ+K x4fGdRb1d27mki3+6aRcL324ysUG7h47p6a/VbL5/h6DvPiHq+7VUuRElbQwncwwTaRQ BDCaUGuTzYjnX16KNdz5MHWjAMq8E9UH29kCoAQwHFfRO4OXqLWhMYcVL+J2W4cOXe7M e2N6T2Q0tzFV0xteZ3JLCbD2bFBpjizXA/wbwdqCDYkRJQX1zyM6a5QMwOONp39bmoh9 LdW0BhTU20lEeVtB8LBVp5sHyAZbv4pCRrsnWoeobMt92VVzDHpwUVDy9GGvYOS7gC/N R7Iw== 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=QixIkQoOQSQ7LFqcqXjzuSKbALdm9LSDFACPeBd6EXc=; b=vGLCNUNrwpKBEAt6jdtjW8oKCeUhZJNvOcQjrGH4UPLDdWmEDuSbLIq7QfE0Knf5z2 +6yykmjncefYpeayMUgwI6MquBp7h3cPHXYv9xdNK+ixOaiussH5WHSHbv3TcRx04KqK AzUVyP3FBmYnlqu5Ahlismt+LADmjQ0kSxEX9QUX+tUZD2Fdu3v8tF095Gl6+AwvVZ0x TSruxBuOQfqmo4s2MA+YWhLrEtxCxN8RiDCog6N1PJcoAGEIVTgqDAB0C2jdMhUhrFOb qa7v9OIUlbCFDlkpgtaBMaDQV4dWnVdPfI5Zu6/p6uCRxCCCy1mmn+lkhq+9/E0GwkHu ncYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sPuMl6U2; 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 35si16287234edj.185.2019.11.20.07.23.11; Wed, 20 Nov 2019 07:23:11 -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=sPuMl6U2; 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 S1729384AbfKTPXK (ORCPT + 26 others); Wed, 20 Nov 2019 10:23:10 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40457 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727711AbfKTPXJ (ORCPT ); Wed, 20 Nov 2019 10:23:09 -0500 Received: by mail-lj1-f193.google.com with SMTP id q2so27997408ljg.7 for ; Wed, 20 Nov 2019 07:23:08 -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=QixIkQoOQSQ7LFqcqXjzuSKbALdm9LSDFACPeBd6EXc=; b=sPuMl6U2vWAMp58080YHiVtXKSPpB2k0OmXi2sz6iOF4t/cdroQZrF51AtOTnbUSYG pYK6hLsSXx+0RFCsG376aH1ZQKf7vFr/XAzd2VvuDrkdjf24hjGgcj1/PRAYsCYniKxm GnO15KtZyhIPLjUAgBj1QeaebzutRyYAPvLOXQz9YYpNaQ/lzYclQRc/pOLBpjQ00uid jfuTNqU/2Q+176VmWMBUwj+pOZxtzTlkjR6bi1saF3ZWl02zo1x9gadO/nUnPAa5UtNu 4/XEszWOOOLgYMm6gvicUG+HHxntTEypzokSrsydV0+890/gSuICeWs+abtF8IHeqFL+ hwsA== 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=QixIkQoOQSQ7LFqcqXjzuSKbALdm9LSDFACPeBd6EXc=; b=PecYpzARCze+TqO20DlrHMHa9qrDEG1RH8kNkN/O5XtAaaEK3ln9ekhCGtsAc2G9Ul DTS+Km9hEZBs/xXssINIKxtc5VxdKyiHdJK7t/dN8eqgohDVDSit34VDZRAnBbxE5Bki OqlQfD3366NHAjmnEvCYE44+TTzVnee6fCgjRWdVSmsksQo7sg15oIgn42UNCVdfitm5 AWJ0jmvmAXPS5IX6+uHkjqS3hLX583l9+qBDsTIjkkQ2b+4LfLVeNw+bxc6I0111hOAv fWd3VfQG8OWKRWteSrLUXs4wH++O8QaPxuqAebktrNFsWYmeDo+2UH8rkxjkd4EbdThf U7Ag== X-Gm-Message-State: APjAAAUk6WmsWd+/tAE8cXF6bVEmMKEx5eR5AaQlyoTwv5Siby75MOjA s9pS0l0eDDAUVm9uOWl5qjOFYA== X-Received: by 2002:a2e:8188:: with SMTP id e8mr3266242ljg.152.1574263387287; Wed, 20 Nov 2019 07:23:07 -0800 (PST) Received: from localhost (c-413e70d5.07-21-73746f28.bbcust.telenor.se. [213.112.62.65]) by smtp.gmail.com with ESMTPSA id e11sm5574688lfc.27.2019.11.20.07.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 07:23:06 -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 v2] net: ipmr: fix suspicious RCU warning Date: Wed, 20 Nov 2019 16:22:55 +0100 Message-Id: <20191120152255.18928-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 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 holds RTNL mutex around the problematic code path, which is function ipmr_rules_init() in ipmr_net_init(). This commit also adds a lockdep_rtnl_is_held() check to the ipmr_for_each_table() macro. Suggested-by: David Miller Reviewed-by: Paul E. McKenney Signed-off-by: Anders Roxell --- net/ipv4/ipmr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 6e68def66822..53dff9a0e60a 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c @@ -110,7 +110,8 @@ static void ipmr_expire_process(struct timer_list *t); #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()) static struct mr_table *ipmr_mr_table_iter(struct net *net, struct mr_table *mrt) @@ -3086,7 +3087,9 @@ static int __net_init ipmr_net_init(struct net *net) if (err) goto ipmr_notifier_fail; + rtnl_lock(); err = ipmr_rules_init(net); + rtnl_unlock(); if (err < 0) goto ipmr_rules_fail;