linux/net/l2tp
James Chapman 5d066766c5 net/l2tp: fix warning in l2tp_exit_net found by syzbot
In l2tp's net exit handler, we check that an IDR is empty before
destroying it:

	WARN_ON_ONCE(!idr_is_empty(&pn->l2tp_tunnel_idr));
	idr_destroy(&pn->l2tp_tunnel_idr);

By forcing memory allocation failures in idr_alloc_32, syzbot is able
to provoke a condition where idr_is_empty returns false despite there
being no items in the IDR. This turns out to be because the radix tree
of the IDR contains only internal radix-tree nodes and it is this that
causes idr_is_empty to return false. The internal nodes are cleaned by
idr_destroy.

Use idr_for_each to check that the IDR is empty instead of
idr_is_empty to avoid the problem.

Reported-by: syzbot+332fe1e67018625f63c9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=332fe1e67018625f63c9
Fixes: 73d33bd063 ("l2tp: avoid using drain_workqueue in l2tp_pre_exit_net")
Signed-off-by: James Chapman <jchapman@katalix.com>
Link: https://patch.msgid.link/20241118140411.1582555-1-jchapman@katalix.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2024-11-26 09:27:07 +01:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
l2tp_core.c net/l2tp: fix warning in l2tp_exit_net found by syzbot 2024-11-26 09:27:07 +01:00
l2tp_core.h l2tp: improve tunnel/session refcount helpers 2024-08-11 04:38:50 +01:00
l2tp_debugfs.c l2tp: improve tunnel/session refcount helpers 2024-08-11 04:38:50 +01:00
l2tp_eth.c netdev_features: convert NETIF_F_LLTX to dev->lltx 2024-09-03 11:36:43 +02:00
l2tp_ip6.c l2tp: improve tunnel/session refcount helpers 2024-08-11 04:38:50 +01:00
l2tp_ip.c l2tp: use skb_queue_purge in l2tp_ip_destroy_sock 2024-08-20 16:52:28 -07:00
l2tp_netlink.c genetlink: hold RCU in genlmsg_mcast() 2024-10-15 17:52:58 -07:00
l2tp_ppp.c l2tp: improve tunnel/session refcount helpers 2024-08-11 04:38:50 +01:00
Makefile l2tp: add tracepoint infrastructure to core 2020-08-22 12:44:37 -07:00
trace.h l2tp: add tracepoint definitions in trace.h 2020-08-22 12:44:37 -07:00