From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796180032; b=KwonHKv9Ef5NPBGDdKm5xfSfF/glPdIEwnpVv/bi1mpFA6bazJvkL+ZtTXTlR+PHjIZT Dy8ebT4Jw9M05GfQtWkahTshwGqKXS14khswyTzGzmDe5xo7QWVA+8eHo7hB7m3CTI3oK xQtnIp1CFyyfDon6gyiSTxkv+bnygOGBt3J+M1g8XAtFkbrDX09JYcEFxdMsxdCYnYdm6 TcnGAG8dmvDnMlm5jjqajxmfPIo+ace5+OX02hY1eTnkPhF2GuY+u52hC6nVNtuCOWHws zSq/1HxuB26b6hm7PpsmpeOO9t+ZSzq/IKClG2cjZ/5JYXhXQ9JorctAvIVJfy8KdJw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796180032; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=Ol/IgGy74S4SYvxJtXne7cNMowHaNKjdtnT3/+7/768=; b=cvRupNQlXDLc0McMb2cLvt11HfjMfBgm2Ecb45JSiyK+IWrd6tYPtULuVNNCnvS7gaCx YcPdUmB1cuGayl1IRb4P66aCdz4C3Y55brgBt/98ApD93fHGSHwB+QHBKCBr5ch8kzSBu lUDMuXsq5/qrRHeD5hO9k2Xwfm87bOZzhNmDRGn+VZh7s9/S49dU+MOEQPs25UWf040XC lLJak1XHdaoJ2N2e1mXd6vqfYyCqqUuf44V5nic8sJ3LBS1wt9VdibCajvXe1TmaYcGdd QlF3NLsM79CR5x6Fj/vKGXpVN6OmYNsRApTjVc/bclJHKkc9BE/9YkX9Cnrb3h1m4kA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=N4faWcz3; arc=none smtp.remote-ip=95.215.58.148 Received: from mta1.migadu.com (out-148.mta1.migadu.com [95.215.58.148]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 218B6606A31A for ; Wed, 2 Dec 2026 02:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 218B6606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=N4faWcz3 X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=6WilB2cGYU9eEBY49sKC6k3fB9QM469XePM2WtrncQs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796180030; v=1; x=1796784830; b=N4faWcz3WKbEOIfg2DPCtXAcLrzasAcwqlTAAE4XArnYIIuvlc6t+Z6ATgBTjHjQK3Z+pip0 19cYp40FYuV4/jJ05fdjUiF72PSCOLX5DGGMCn+ScyK4IBNDXkwBhGfO09g08XbUyD0C/5BKeNV 53u4gsj7hg4JAVzDS6Mb8XGw= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id af8a1ea5a6726ace; Wed, 02 Dec 2026 02:53:49 +0000 X-Mizu-Trace-ID: af8a1ea5a6726ace X-Migadu-Flow: FLOW_OUT From: Jiayuan Chen To: tj@kernel.org, jiangshanlai@gmail.com Cc: Jiayuan Chen , syzbot+a73d496b2c6919c3f12c@syzkaller.appspotmail.com, linux-kernel@vger.kernel.org Subject: [PATCH] workqueue: Fix false leak report when lockdep is turned off Date: Wed, 2 Dec 2026 10:52:49 +0800 Message-ID: <20261202025250.372140-1-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 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 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 --- 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