Kuniyuki Iwashima
d2492688bb
nfc: nci: Fix race between rfkill and nci_unregister_device().
syzbot reported the splat below [0] without a repro.
It indicates that struct nci_dev.cmd_wq had been destroyed before
nci_close_device() was called via rfkill.
nci_dev.cmd_wq is only destroyed in nci_unregister_device(), which
(I think) was called from virtual_ncidev_close() when syzbot close()d
an fd of virtual_ncidev.
The problem is that nci_unregister_device() destroys nci_dev.cmd_wq
first and then calls nfc_unregister_device(), which removes the
device from rfkill by rfkill_unregister().
So, the device is still visible via rfkill even after nci_dev.cmd_wq
is destroyed.
Let's unregister the device from rfkill first in nci_unregister_device().
Note that we cannot call nfc_unregister_device() before
nci_close_device() because
1) nfc_unregister_device() calls device_del() which frees
all memory allocated by devm_kzalloc() and linked to
ndev->conn_info_list
2) nci_rx_work() could try to queue nci_conn_info to
ndev->conn_info_list which could be leaked
Thus, nfc_unregister_device() is split into two functions so we
can remove rfkill interfaces only before nci_close_device().
[0]:
DEBUG_LOCKS_WARN_ON(1)
WARNING: kernel/locking/lockdep.c:238 at hlock_class kernel/locking/lockdep.c:238 [inline], CPU#0: syz.0.8675/6349
WARNING: kernel/locking/lockdep.c:238 at check_wait_context kernel/locking/lockdep.c:4854 [inline], CPU#0: syz.0.8675/6349
WARNING: kernel/locking/lockdep.c:238 at __lock_acquire+0x39d/0x2cf0 kernel/locking/lockdep.c:5187, CPU#0: syz.0.8675/6349
Modules linked in:
CPU: 0 UID: 0 PID: 6349 Comm: syz.0.8675 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/13/2026
RIP: 0010:hlock_class kernel/locking/lockdep.c:238 [inline]
RIP: 0010:check_wait_context kernel/locking/lockdep.c:4854 [inline]
RIP: 0010:__lock_acquire+0x3a4/0x2cf0 kernel/locking/lockdep.c:5187
Code: 18 00 4c 8b 74 24 08 75 27 90 e8 17 f2 fc 02 85 c0 74 1c 83 3d 50 e0 4e 0e 00 75 13 48 8d 3d 43 f7 51 0e 48 c7 c6 8b 3a de 8d <67> 48 0f b9 3a 90 31 c0 0f b6 98 c4 00 00 00 41 8b 45 20 25 ff 1f
RSP: 0018:ffffc9000c767680 EFLAGS: 00010046
RAX: 0000000000000001 RBX: 0000000000040000 RCX: 0000000000080000
RDX: ffffc90013080000 RSI: ffffffff8dde3a8b RDI: ffffffff8ff24ca0
RBP: 0000000000000003 R08: ffffffff8fef35a3 R09: 1ffffffff1fde6b4
R10: dffffc0000000000 R11: fffffbfff1fde6b5 R12: 00000000000012a2
R13: ffff888030338ba8 R14: ffff888030338000 R15: ffff888030338b30
FS: 00007fa5995f66c0(0000) GS:ffff8881256f8000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f7e72f842d0 CR3: 00000000485a0000 CR4: 00000000003526f0
Call Trace:
<TASK>
lock_acquire+0x106/0x330 kernel/locking/lockdep.c:5868
touch_wq_lockdep_map+0xcb/0x180 kernel/workqueue.c:3940
__flush_workqueue+0x14b/0x14f0 kernel/workqueue.c:3982
nci_close_device+0x302/0x630 net/nfc/nci/core.c:567
nci_dev_down+0x3b/0x50 net/nfc/nci/core.c:639
nfc_dev_down+0x152/0x290 net/nfc/core.c:161
nfc_rfkill_set_block+0x2d/0x100 net/nfc/core.c:179
rfkill_set_block+0x1d2/0x440 net/rfkill/core.c:346
rfkill_fop_write+0x461/0x5a0 net/rfkill/core.c:1301
vfs_write+0x29a/0xb90 fs/read_write.c:684
ksys_write+0x150/0x270 fs/read_write.c:738
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fa59b39acb9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa5995f6028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fa59b615fa0 RCX: 00007fa59b39acb9
RDX: 0000000000000008 RSI: 0000200000000080 RDI: 0000000000000007
RBP: 00007fa59b408bf7 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fa59b616038 R14: 00007fa59b615fa0 R15: 00007ffc82218788
</TASK>
Fixes: 6a2968aaf5 ("NFC: basic NCI protocol implementation")
Reported-by: syzbot+f9c5fd1a0874f9069dce@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/695e7f56.050a0220.1c677c.036c.GAE@google.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260127040411.494931-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-01-28 19:32:26 -08:00
..
2025-11-03 16:49:53 +09:00
2025-12-01 16:21:16 -05:00
2024-10-08 15:33:49 -07:00
2024-12-09 14:44:59 -08:00
2025-10-29 20:04:55 -07:00
2025-12-01 13:53:53 -08:00
2025-12-15 15:02:44 +01:00
2025-11-20 17:44:23 -08:00
2026-01-28 19:32:26 -08:00
2025-09-04 10:19:17 +02:00
2024-10-24 16:03:40 +02:00
2025-11-07 18:53:57 -08:00
2025-11-14 18:00:34 -08:00
2025-08-28 16:46:23 -07:00
2020-02-28 14:51:30 +01:00
2025-09-02 15:52:24 -07:00
2025-11-03 17:40:46 -08:00
2025-04-24 17:03:45 -07:00
2025-07-08 18:05:25 -07:00
2025-07-07 16:55:54 -07:00
2025-07-02 14:22:02 -07:00
2022-07-22 12:53:22 +01:00
2023-03-21 21:32:18 -07:00
2025-03-24 10:26:53 +00:00
2022-08-09 22:14:02 -07:00
2021-12-13 12:34:09 +00:00
2025-09-09 10:56:02 +02:00
2024-08-26 09:37:22 -07:00
2025-09-09 10:56:02 +02:00
2026-01-23 13:55:56 -08:00
2021-03-26 17:43:55 +01:00
2025-02-27 14:03:14 +01:00
2024-10-02 17:23:23 -04:00
2022-11-16 11:31:47 +02:00
2026-01-20 10:02:01 +01:00
2024-03-06 21:01:26 +01:00
2025-05-30 19:53:51 -07:00
2024-10-02 17:23:23 -04:00
2025-09-14 11:55:04 -07:00
2021-12-22 15:03:47 -08:00
2022-07-22 12:53:22 +01:00
2023-07-14 20:39:29 -07:00
2022-07-24 18:39:17 -06:00
2023-07-27 17:17:32 -07:00
2022-07-22 12:53:22 +01:00
2023-01-20 09:33:22 +00:00
2025-11-20 19:01:22 -08:00
2026-01-13 10:12:11 +01:00
2025-02-11 11:58:17 +01:00
2023-10-24 13:08:14 -07:00
2025-12-23 10:32:08 +01:00
2024-05-08 10:35:09 +01:00
2019-12-16 16:09:44 -08:00
2024-08-26 09:37:23 -07:00
2025-09-14 14:28:12 -07:00
2024-05-29 17:34:49 -07:00
2025-08-29 19:36:31 -07:00
2024-11-13 18:49:50 -08:00
2024-08-26 09:37:23 -07:00
2022-07-22 12:53:22 +01:00
2024-04-01 21:27:08 -07:00
2022-07-22 12:53:22 +01:00
2021-12-06 16:06:02 -08:00
2024-10-11 15:35:05 -07:00
2025-04-15 17:54:56 -07:00
2022-07-28 22:21:54 -07:00
2024-07-15 09:14:39 -07:00
2024-10-30 17:33:53 -07:00
2025-08-26 17:34:31 -07:00
2023-04-12 16:40:39 -07:00
2022-12-01 15:09:10 +01:00
2023-08-08 15:58:23 -07:00
2022-07-22 12:53:22 +01:00
2021-10-18 12:54:41 +01:00
2025-09-03 15:16:49 -07:00
2022-10-31 10:43:04 +00:00
2024-04-01 10:49:28 +01:00
2025-11-14 18:00:08 -08:00
2023-06-10 00:11:41 -07:00
2024-05-07 01:35:55 +02:00
2022-07-22 12:53:22 +01:00
2023-07-28 14:07:59 -07:00
2026-01-13 10:12:11 +01:00
2024-08-26 09:37:23 -07:00
2025-09-11 12:22:38 +02:00
2024-05-08 10:35:09 +01:00
2025-10-30 08:38:51 +01:00
2023-11-20 11:43:03 +01:00
2024-02-26 18:40:34 -08:00
2025-03-24 12:10:13 -07:00
2025-09-22 11:38:43 -07:00
2025-11-04 19:10:33 -08:00
2025-11-25 19:28:29 -08:00
2025-08-26 17:34:31 -07:00
2021-10-15 11:33:08 +01:00
2025-12-10 01:15:27 -08:00
2025-09-23 10:12:15 +02:00
2025-10-27 18:04:59 -07:00
2025-09-23 10:12:15 +02:00
2024-12-17 19:37:00 -08:00
2024-02-28 11:19:41 +00:00
2021-11-16 13:16:54 +00:00
2025-04-24 09:29:56 +02:00
2025-09-18 10:17:09 +02:00
2025-07-02 14:32:30 -07:00
2025-08-26 17:34:31 -07:00
2026-01-08 18:02:35 -08:00
2025-08-13 08:34:33 +02:00
2025-11-04 19:10:33 -08:00
2025-03-21 17:36:49 +08:00
2022-07-22 12:53:22 +01:00
2025-12-10 01:15:27 -08:00
2025-11-04 19:10:33 -08:00
2025-11-04 19:10:33 -08:00
2024-10-09 08:53:01 +02:00
2025-08-13 18:18:33 -07:00
2025-04-15 17:54:56 -07:00
2024-12-06 17:43:08 -08:00
2023-08-04 15:33:17 -07:00
2023-08-04 15:33:17 -07:00
2024-07-15 08:51:01 -07:00
2023-07-20 10:46:28 +02:00
2021-10-13 09:40:46 -07:00
2024-08-26 09:37:23 -07:00
2022-07-22 12:53:22 +01:00
2022-07-22 12:53:22 +01:00
2024-07-15 08:51:19 -07:00
2021-11-07 19:25:29 +00:00
2025-07-02 14:32:30 -07:00
2025-11-10 10:38:37 +01:00
2024-10-02 17:23:23 -04:00
2025-01-20 12:20:42 +00:00
2025-07-15 12:08:39 +02:00
2024-11-09 09:04:54 -08:00
2020-03-02 11:16:27 -08:00
2021-03-26 15:14:56 -07:00
2022-07-22 12:53:22 +01:00
2020-05-29 21:20:20 -07:00
2025-04-15 08:21:46 -07:00
2022-11-18 12:14:55 +00:00
2022-07-22 12:53:22 +01:00
2025-07-10 15:27:32 -07:00
2024-11-09 13:22:57 -08:00
2025-10-24 17:57:20 -07:00
2024-11-30 13:41:50 -08:00
2025-09-29 11:20:29 -07:00
2024-10-10 08:30:22 -07:00
2021-12-10 06:38:26 -08:00
2025-05-22 09:42:41 -07:00
2025-03-12 13:32:35 -07:00
2025-09-04 10:19:17 +02:00
2025-04-09 17:01:51 -07:00
2022-07-22 12:53:22 +01:00
2023-11-20 10:15:16 -08:00
2024-11-21 08:28:08 -08:00
2025-07-02 15:39:04 -07:00
2025-10-28 17:41:46 -07:00
2019-11-12 08:18:03 -08:00
2022-07-22 12:53:22 +01:00
2025-04-24 09:29:56 +02:00
2025-10-20 17:13:40 -07:00
2023-07-14 20:39:29 -07:00
2025-06-13 18:17:08 -07:00
2023-07-14 20:39:30 -07:00
2025-11-04 19:10:33 -08:00
2025-11-24 18:53:14 -08:00
2025-11-25 16:10:32 +01:00
2022-07-22 12:53:22 +01:00
2025-10-16 12:04:47 -07:00
2024-03-07 21:12:43 -08:00
2024-07-11 18:11:31 -07:00
2022-07-22 12:53:22 +01:00
2025-09-18 12:32:06 +02:00
2025-09-14 11:35:17 -07:00
2023-03-17 08:56:37 +00:00
2024-08-26 09:37:23 -07:00
2024-08-26 09:37:23 -07:00
2025-11-07 18:05:25 -08:00
2025-08-27 07:43:08 -07:00
2025-08-29 19:36:32 -07:00
2023-06-19 11:32:58 -07:00
2025-09-03 15:08:20 -07:00
2023-07-14 20:39:30 -07:00
2025-04-11 18:58:10 -07:00
2025-02-21 15:28:03 -08:00
2025-11-25 16:10:32 +01:00
2025-07-04 09:32:35 +02:00
2025-04-11 18:58:10 -07:00
2025-08-26 18:11:29 -07:00
2024-06-24 16:41:23 -07:00
2024-05-30 18:29:38 -07:00
2025-11-06 13:38:11 +01:00
2025-11-10 11:19:41 -08:00
2025-09-08 18:06:21 -07:00
2024-08-02 17:16:59 -07:00
2025-12-05 13:52:43 -08:00
2023-10-04 11:49:20 -07:00
2022-07-22 12:53:22 +01:00
2025-05-05 16:48:12 -07:00
2024-02-16 09:36:37 +00:00
2024-02-14 10:49:37 +01:00
2025-09-11 19:05:56 -07:00
2025-09-18 08:47:52 +02:00
2023-12-04 14:45:26 -08:00
2025-11-14 18:00:08 -08:00
2025-07-11 11:00:57 -07:00
2025-08-25 17:53:35 -07:00
2023-07-28 14:07:59 -07:00
2025-10-31 06:46:03 -07:00
2023-08-01 15:06:27 -07:00
2022-12-12 15:04:39 -08:00
2022-07-22 12:53:22 +01:00
2025-06-24 16:31:36 -07:00
2025-11-04 19:10:33 -08:00
2023-09-14 16:16:36 +02:00
2025-11-04 19:10:32 -08:00
2025-06-17 18:18:46 -07:00
2025-07-14 17:19:13 -07:00
2022-07-22 12:53:22 +01:00
2025-11-06 16:46:11 -08:00
2025-11-11 10:21:08 +01:00
2025-09-24 10:22:37 -07:00
2025-10-30 11:52:31 +01:00
2025-11-04 16:10:53 +01:00