All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Qian Cai <cai@lca.pw>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.4 02/29] ipv4: fix a RCU-list lock in fib_triestat_seq_show
Date: Sat, 11 Apr 2020 14:08:32 +0200	[thread overview]
Message-ID: <20200411115407.957243103@linuxfoundation.org> (raw)
In-Reply-To: <20200411115407.651296755@linuxfoundation.org>

From: Qian Cai <cai@lca.pw>

[ Upstream commit fbe4e0c1b298b4665ee6915266c9d6c5b934ef4a ]

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

Fix it by adding a pair of rcu_read_lock/unlock() and use
cond_resched_rcu() to avoid the situation where walking of a large
number of items  may prevent scheduling for a long time.

Signed-off-by: Qian Cai <cai@lca.pw>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv4/fib_trie.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2230,6 +2230,7 @@ static int fib_triestat_seq_show(struct
 		   " %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;
@@ -2249,7 +2250,9 @@ static int fib_triestat_seq_show(struct
 			trie_show_usage(seq, t->stats);
 #endif
 		}
+		cond_resched_rcu();
 	}
+	rcu_read_unlock();
 
 	return 0;
 }



  parent reply	other threads:[~2020-04-11 12:10 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 12:08 [PATCH 4.4 00/29] 4.4.219-rc1 review Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 01/29] drm/bochs: downgrade pci_request_region failure from error to warning Greg Kroah-Hartman
2020-04-11 12:08 ` Greg Kroah-Hartman [this message]
2020-04-11 12:08 ` [PATCH 4.4 03/29] net, ip_tunnel: fix interface lookup with no key Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 04/29] sctp: fix possibly using a bad saddr with a given dst Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 05/29] l2tp: Correctly return -EBADF from pppol2tp_getname Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 06/29] net: l2tp: Make l2tp_ip6 namespace aware Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 07/29] l2tp: fix race in l2tp_recv_common() Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 08/29] l2tp: ensure session cant get removed during pppol2tp_session_ioctl() Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 09/29] l2tp: fix duplicate session creation Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 10/29] l2tp: Refactor the codes with existing macros instead of literal number Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 11/29] l2tp: ensure sessions are freed after their PPPOL2TP socket Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 12/29] l2tp: fix race between l2tp_session_delete() and l2tp_tunnel_closeall() Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 13/29] usb: gadget: uac2: Drop unused device qualifier descriptor Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 14/29] usb: gadget: printer: " Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 15/29] padata: always acquire cpu_hotplug_lock before pinst->lock Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 16/29] mm: mempolicy: require at least one nodeid for MPOL_PREFERRED Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 17/29] net: stmmac: dwmac1000: fix out-of-bounds mac address reg setting Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 18/29] slcan: Dont transmit uninitialized stack data in padding Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 19/29] random: always use batched entropy for get_random_u{32,64} Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 20/29] tools/accounting/getdelays.c: fix netlink attribute length Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 21/29] power: supply: axp288_charger: Fix unchecked return value Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 22/29] xen-netfront: Fix mismatched rtnl_unlock Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 23/29] xen-netfront: Update features after registering netdev Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 24/29] ASoC: jz4740-i2s: Fix divider written at incorrect offset in register Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 25/29] IB/hfi1: Call kobject_put() when kobject_init_and_add() fails Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 26/29] Bluetooth: RFCOMM: fix ODEBUG bug in rfcomm_dev_ioctl Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 27/29] RDMA/cm: Update num_paths in cma_resolve_iboe_route error flow Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 28/29] clk: qcom: rcg: Return failure for RCG update Greg Kroah-Hartman
2020-04-11 12:08 ` [PATCH 4.4 29/29] drm_dp_mst_topology: fix broken drm_dp_sideband_parse_remote_dpcd_read() Greg Kroah-Hartman
2020-04-11 20:37 ` [PATCH 4.4 00/29] 4.4.219-rc1 review Guenter Roeck
2020-04-12 10:05 ` Naresh Kamboju
2020-04-13 19:44 ` Chris Paterson
2020-04-14 10:35 ` Jon Hunter
2020-04-14 10:35   ` Jon Hunter
     [not found]   ` <63b31c56-b5c9-2ced-ee00-772fa9a1dcaf-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-04-14 10:57     ` Greg Kroah-Hartman
2020-04-14 10:57       ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200411115407.957243103@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=cai@lca.pw \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.