* [PATCH] workqueue: Fix false leak report when lockdep is turned off
@ 2026-12-02 2:52 Jiayuan Chen
0 siblings, 0 replies; only message in thread
From: Jiayuan Chen @ 2026-12-02 2:52 UTC (permalink / raw)
To: tj, jiangshanlai; +Cc: Jiayuan Chen, syzbot+a73d496b2c6919c3f12c, linux-kernel
process_one_work() reads lockdep_depth(current) before and after the work
function and complains if they differ. But lockdep_depth() returns 0 once
debug_locks is cleared:
#define lockdep_depth(tsk) (debug_locks ? (tsk)->lockdep_depth : 0)
A BH work item runs on top of whatever task is current, so the start
depth can be non-zero. If lockdep gets turned off while the work function
is running, e.g. by a lockdep splat on another CPU, the second read
returns 0 and we get a bogus report:
BUG: workqueue leaked atomic, lock or RCU: syz-executor[6626]
preempt=0x00000000 lock=4->0 RCU=2->2 workfn=usb_giveback_urb_bh
INFO: lockdep is turned off.
CPU: 0 UID: 0 PID: 6626 Comm: syz-executor Not tainted syzkaller #0 PREEMPT_{RT,(full)}
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
process_one_work kernel/workqueue.c:3516 [inline]
process_scheduled_works+0x12c2/0x1630 kernel/workqueue.c:3578
bh_worker+0x4b3/0xbb0 kernel/workqueue.c:3885
tasklet_hi_action+0xf/0x70 kernel/softirq.c:1028
handle_softirqs+0x1d4/0x6c0 kernel/softirq.c:669
__do_softirq kernel/softirq.c:703 [inline]
__local_bh_enable_ip+0x16f/0x2b0 kernel/softirq.c:325
local_bh_enable include/linux/bottom_half.h:33 [inline]
__alloc_skb+0x1b1/0x7a0 net/core/skbuff.c:700
alloc_skb include/linux/skbuff.h:1390 [inline]
nlmsg_new include/net/netlink.h:1055 [inline]
rtmsg_fib+0xda/0x440 net/ipv4/fib_semantics.c:584
fib_table_insert+0xd54/0x1b10 net/ipv4/fib_trie.c:1381
fib_magic+0x43b/0x530 net/ipv4/fib_frontend.c:1147
fib_add_ifaddr+0x376/0x5d0 net/ipv4/fib_frontend.c:1184
fib_netdev_event+0x382/0x490 net/ipv4/fib_frontend.c:1529
notifier_call_chain+0x1a5/0x3d0 kernel/notifier.c:86
call_netdevice_notifiers_extack net/core/dev.c:2351 [inline]
call_netdevice_notifiers net/core/dev.c:2365 [inline]
__dev_notify_flags+0x31e/0x510 net/core/dev.c:10063
netif_change_flags+0xde/0x1b0 net/core/dev.c:10092
do_setlink+0xdd6/0x47a0 net/core/rtnetlink.c:3294
rtnl_changelink net/core/rtnetlink.c:3942 [inline]
__rtnl_newlink net/core/rtnetlink.c:4113 [inline]
rtnl_newlink+0x15b0/0x1c30 net/core/rtnetlink.c:4252
rtnetlink_rcv_msg+0x802/0xc00 net/core/rtnetlink.c:7169
netlink_rcv_skb+0x226/0x4a0 net/netlink/af_netlink.c:2585
netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
netlink_unicast+0x90c/0xac0 net/netlink/af_netlink.c:1362
netlink_sendmsg+0x7f0/0xb20 net/netlink/af_netlink.c:1921
sock_sendmsg_nosec+0x14e/0x190 net/socket.c:800
__sock_sendmsg net/socket.c:818 [inline]
__sys_sendto+0x41e/0x5d0 net/socket.c:2283
__do_sys_sendto net/socket.c:2290 [inline]
__se_sys_sendto net/socket.c:2286 [inline]
__x64_sys_sendto+0xde/0x100 net/socket.c:2286
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x171/0x540 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Lockdep stops tracking the depth once it is off, so skip the depth check
in that case. debug_locks is tested after the depth is read: it is not
set back at runtime, so if it is still set the depth we read is valid.
In the syzbot report the lockdep splat came from an unrelated kworker
on the other CPU.
Fixes: 4cb1ef64609f ("workqueue: Implement BH workqueues to eventually replace tasklets")
Reported-by: syzbot+a73d496b2c6919c3f12c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=a73d496b2c6919c3f12c
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
---
kernel/workqueue.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index a2a441837a9d..e64c643a6f5c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3506,7 +3506,8 @@ __acquires(&pool->lock)
lock_map_release(pwq->wq->lockdep_map);
if (unlikely((worker->task && in_atomic()) ||
- lockdep_depth(current) != lockdep_start_depth ||
+ (lockdep_depth(current) != lockdep_start_depth &&
+ debug_locks) ||
rcu_preempt_depth() != rcu_start_depth)) {
pr_err("BUG: workqueue leaked atomic, lock or RCU: %s[%d]\n"
" preempt=0x%08x lock=%d->%d RCU=%d->%d workfn=%ps\n",
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 2:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 2:52 [PATCH] workqueue: Fix false leak report when lockdep is turned off Jiayuan Chen
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.