Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp752921ybb; Wed, 25 Mar 2020 08:57:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs4x1ANrr+/egsjeQsnT2m7/01atAndYvXOZx89YAsjWTk4LQoIBC4od8L4W96BKLw9kQoY X-Received: by 2002:a4a:84c2:: with SMTP id o2mr1463774oog.47.1585151869117; Wed, 25 Mar 2020 08:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585151869; cv=none; d=google.com; s=arc-20160816; b=HvRE0tl6zV2qYTvj4OoxfBQeSy4inWO8BsBd9CXF8ID+zWcKIp5JGcsDXdUBuJfQgX F875mJauAvohTY3BCCsDvyNJWS+0TAQv5Lg7vOkuN9jQNqDcV/GF6/9SWQy1E45v41sn qfl0OyZefy7cuGZZ9WaP70WB5UVXP8j5RyOfryp9jTs5NZWsOBeL9W9R8X0j7O+tYc3Y z2LzRDwzMLJZpm27Nff/etuVb1KtiflvJcviuc64fMJHYQxuvp6l40ar8ZCwhGKOfnr/ Bcngz9qaF0Kyjeq9iyQp7rQ/xAJ28XTyx5+OlUlNJY5ANfE9QdFOp2cIvTzw5y6ckSae VWBA== 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=5LjboPnDfMYr+D+3numlwyKRNovhORGQjxZDfSq6m9Y=; b=sJQsnDhuxgq8FWhapXgAVgZYLJgjHAljsdUN2p2zK4QMC4bi5xcEhfJfEGm3aZ+Hi0 MX2asDK0bZw3kEtSCUq8UQXhguUNCtqtqljM2j4od3Xn3W7veJUY8izLtA9elYHXIt3C cTvvik+cm1Yy/+sgS/hajBpaKHfPm5TjkzBKqW5+i26A3p8Czcw96SwYp7ZgmQ3XHjzk MtccPwQmivJWatWw5XfOCOahwwpJ5C6MgqD95tJAVGSvpR+gaLQMxJJlqFJZP3vrC0Ij Lv1IciYbqkTSdEWxNxWxXilV7wnKlqw7cUX4fxQO/TWZmSGuZaeO921Re/K2E72zCQSE vQEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=hUPBtEbE; 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 w23si11411864oti.18.2020.03.25.08.57.34; Wed, 25 Mar 2020 08:57:49 -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=@lca.pw header.s=google header.b=hUPBtEbE; 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 S1727967AbgCYP4D (ORCPT + 99 others); Wed, 25 Mar 2020 11:56:03 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:35760 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbgCYP4D (ORCPT ); Wed, 25 Mar 2020 11:56:03 -0400 Received: by mail-qt1-f196.google.com with SMTP id e14so2587041qts.2 for ; Wed, 25 Mar 2020 08:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5LjboPnDfMYr+D+3numlwyKRNovhORGQjxZDfSq6m9Y=; b=hUPBtEbERszA+YII5Yxm3jnhf4gWvrQeMIUx7nRUKWsaVY/hTEbkcVwZ824Se5rjur x16y9PSdBsh167UfAZB5rT8bdfE8B41JnUCsPalmpfBxfrdDF/j6w9juDr9y/qiY8f1h pNQfeGBclLRBzT/fGnw6z3HBUlqE3UAo1M36/bqz9zfViGSlGkvioTbJiS2pCU7VlNop OQdFs/PIbIFnGIxs+zlMC8scqnUkRuWE0TWt3fVrW/7JpC5dxhnn5niw6m4tH5ntSp8s qpps1r0bF2/oiW3GuFKkRAgQUlhbibiMzAZHDiUoxY2kjLYpzPOqOSgyvIRDqfhyupYy 4Vew== 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=5LjboPnDfMYr+D+3numlwyKRNovhORGQjxZDfSq6m9Y=; b=SuH0sbLIYT1Zh6V9of6T1LiLf62EUAQKU2q9r8NcRWB+vm/osRDkZLyQ16+t8syjtJ f8INOGwEx6qDJjVnJFun5GSxgOgeHuOd9d64vBl+qU/MSmAOOwVwtTzjTjNGE+a2cdPJ CosjNJoXnA42KRbgZ4bJ5N1SiEHE0xM3cXu7U9/HyE/nXjjzunOOJj+ERlRrD9T+QDdR s/F8z0NpN8KTim8PxoZc5wfrUk0SFY9i770LGhRSPO5t3CqvGMt7nRUFjW9QwgjKlgPK MNxYJLUAC1arGvoDbAfkxpuTczR/bJU1/C6URLUzu9TyBLVj94UYU/19X+hrRhgpAF7o skFA== X-Gm-Message-State: ANhLgQ14bnqHn4+meIQZExP6/fcaX9SrnJIarwc25harY6wVLhZIGzS/ NZJjT+p0yTiiLcqSapdi8x3ItA== X-Received: by 2002:ac8:346f:: with SMTP id v44mr3526427qtb.205.1585151761950; Wed, 25 Mar 2020 08:56:01 -0700 (PDT) Received: from ovpn-66-69.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id t23sm17931750qtj.63.2020.03.25.08.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Mar 2020 08:55:47 -0700 (PDT) From: Qian Cai To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH] ipv4: fix a RCU-list lock in fib_triestat_seq_show Date: Wed, 25 Mar 2020 11:55:32 -0400 Message-Id: <20200325155532.7238-1-cai@lca.pw> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) 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 fib_triestat_seq_show() calls hlist_for_each_entry_rcu(tb, head, tb_hlist) without rcu_read_lock() will trigger a warning, net/ipv4/fib_trie.c:2579 RCU-list traversed in non-reader section!! other info that might help us debug this: rcu_scheduler_active = 2, debug_locks = 1 1 lock held by proc01/115277: #0: c0000014507acf00 (&p->lock){+.+.}-{3:3}, at: seq_read+0x58/0x670 Call Trace: dump_stack+0xf4/0x164 (unreliable) lockdep_rcu_suspicious+0x140/0x164 fib_triestat_seq_show+0x750/0x880 seq_read+0x1a0/0x670 proc_reg_read+0x10c/0x1b0 __vfs_read+0x3c/0x70 vfs_read+0xac/0x170 ksys_read+0x7c/0x140 system_call+0x5c/0x68 Signed-off-by: Qian Cai --- net/ipv4/fib_trie.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index ff0c24371e33..73fa37476f03 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c @@ -2577,6 +2577,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v) " %zd bytes, size of tnode: %zd bytes.\n", LEAF_SIZE, TNODE_SIZE(0)); + rcu_read_lock(); for (h = 0; h < FIB_TABLE_HASHSZ; h++) { struct hlist_head *head = &net->ipv4.fib_table_hash[h]; struct fib_table *tb; @@ -2597,6 +2598,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v) #endif } } + rcu_read_unlock(); return 0; } -- 2.21.0 (Apple Git-122.2)