syzbot


BUG: sleeping function called from invalid context in lock_sock_nested (2)

Status: upstream: reported C repro on 2025/02/23 00:56
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+3fd940c701b7555d6f7b@syzkaller.appspotmail.com
First crash: 273d, last: 11d
Fix bisection: failed (error log, bisect log)
  
Bug presence (3)
Date Name Commit Repro Result
2025/04/25 linux-6.1.y (ToT) 535ec20c5027 C [report] BUG: sleeping function called from invalid context in lock_sock_nested
2025/03/10 upstream (ToT) 80e54e84911a C [report] BUG: sleeping function called from invalid context in lock_sock_nested
2025/04/25 upstream (ToT) 02ddfb981de8 C Didn't crash
Similar bugs (23)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 BUG: sleeping function called from invalid context in lock_sock_nested (2) 5 C done 3909 1533d 1626d 1/1 fixed on 2021/10/12 13:38
upstream BUG: sleeping function called from invalid context in lock_sock_nested (2) bluetooth 5 C done error 19391 1565d 2100d 20/29 fixed on 2021/11/10 13:22
linux-4.14 BUG: sleeping function called from invalid context in lock_sock_nested 5 1 2335d 2335d 0/1 auto-closed as invalid on 2019/10/30 11:24
linux-4.14 BUG: sleeping function called from invalid context in lock_sock_nested (2) 5 syz done 1 2120d 2180d 1/1 fixed on 2020/03/04 10:17
linux-4.19 BUG: sleeping function called from invalid context in lock_sock_nested 5 syz done 1 2150d 2180d 1/1 fixed on 2020/02/05 13:33
linux-6.1 BUG: sleeping function called from invalid context in lock_sock_nested 5 7 491d 512d 0/3 auto-obsoleted due to no activity on 2024/10/28 05:57
upstream BUG: sleeping function called from invalid context in lock_sock_nested bpf net 5 C 1232 2104d 2180d 15/29 fixed on 2020/02/18 14:31
linux-4.14 BUG: sleeping function called from invalid context in lock_sock_nested (3) 5 syz error 144 1120d 1626d 0/1 upstream: reported syz repro on 2021/06/10 20:33
upstream BUG: sleeping function called from invalid context in lock_sock_nested (3) net bluetooth 19 C inconclusive error 153 80d 558d 0/29 auto-obsoleted due to no activity on 2025/11/12 14:25
linux-5.15 BUG: sleeping function called from invalid context in lock_sock_nested missing-backport origin:lts-only 19 C done 25 32d 512d 0/3 upstream: reported C repro on 2024/06/29 07:50
upstream BUG: unable to handle kernel paging request in lock_sock_nested bluetooth 17 43 1495d 1935d 0/29 auto-closed as invalid on 2022/02/16 22:16
linux-4.19 KASAN: wild-memory-access Write in lock_sock_nested 23 2 1759d 1828d 0/1 auto-closed as invalid on 2021/05/28 14:35
linux-4.14 general protection fault in lock_sock_nested 2 4 1660d 1878d 0/1 auto-closed as invalid on 2021/09/04 19:35
linux-4.19 KASAN: use-after-free Read in lock_sock_nested 23 C 471 998d 2311d 0/1 upstream: reported C repro on 2019/07/26 21:27
linux-4.14 KASAN: use-after-free Read in lock_sock_nested 19 C inconclusive 331 1038d 2405d 0/1 upstream: reported C repro on 2019/04/24 06:28
upstream KASAN: use-after-free Read in lock_sock_nested hams 19 C inconclusive done 1856 907d 2516d 0/29 auto-obsoleted due to no activity on 2023/08/23 09:06
upstream general protection fault in lock_sock_nested bluetooth 19 C done done 3767 1h03m 804d 0/29 upstream: reported C repro on 2023/09/11 07:52
linux-5.15 general protection fault in lock_sock_nested missing-backport origin:upstream 8 C error 144 13d 597d 0/3 upstream: reported C repro on 2024/04/04 13:25
linux-4.14 BUG: unable to handle kernel paging request in lock_sock_nested 8 4 1653d 1773d 0/1 auto-closed as invalid on 2021/09/11 11:51
linux-6.1 general protection fault in lock_sock_nested origin:upstream missing-backport 19 C inconclusive 188 3d04h 588d 0/3 upstream: reported C repro on 2024/04/14 08:46
upstream KASAN: slab-out-of-bounds Read in lock_sock_nested bluetooth 17 syz unreliable done 23 1489d 1929d 0/29 auto-obsoleted due to no activity on 2022/09/29 10:19
linux-4.19 KASAN: slab-out-of-bounds Read in lock_sock_nested 23 14 1172d 1836d 0/1 auto-obsoleted due to no activity on 2023/01/05 15:59
linux-6.6 general protection fault in lock_sock_nested origin:upstream 2 C 24 22d 157d 0/2 upstream: reported C repro on 2025/06/19 04:51
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2025/10/24 14:37 1h35m fix candidate upstream OK (0) job log
2025/03/27 03:34 18m bisect fix linux-6.1.y error job log

Sample crash report:
BUG: sleeping function called from invalid context at net/core/sock.c:3495
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 4396, name: kworker/u5:2
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
6 locks held by kworker/u5:2/4396:
 #0: ffff0000d14bf938 ((wq_completion)hci1#2){+.+.}-{0:0}, at: process_one_work+0x6b4/0x13a8 kernel/workqueue.c:2265
 #1: ffff800020d37c20 ((work_completion)(&hdev->rx_work)){+.+.}-{0:0}, at: process_one_work+0x6f8/0x13a8 kernel/workqueue.c:2267
 #2: ffff0000cabcc078 (&hdev->lock){+.+.}-{3:3}, at: hci_sync_conn_complete_evt+0x98/0x90c net/bluetooth/hci_event.c:5018
 #3: ffff800017885ba8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_connect_cfm include/net/bluetooth/hci_core.h:1805 [inline]
 #3: ffff800017885ba8 (hci_cb_list_lock){+.+.}-{3:3}, at: hci_sync_conn_complete_evt+0x3f8/0x90c net/bluetooth/hci_event.c:5104
 #4: ffff0000c9b6c020 (&conn->lock#2){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #4: ffff0000c9b6c020 (&conn->lock#2){+.+.}-{2:2}, at: sco_conn_ready net/bluetooth/sco.c:1297 [inline]
 #4: ffff0000c9b6c020 (&conn->lock#2){+.+.}-{2:2}, at: sco_connect_cfm+0x25c/0x8fc net/bluetooth/sco.c:1382
 #5: ffff0000efde1130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1792 [inline]
 #5: ffff0000efde1130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_conn_ready net/bluetooth/sco.c:1310 [inline]
 #5: ffff0000efde1130 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at: sco_connect_cfm+0x3cc/0x8fc net/bluetooth/sco.c:1382
Preemption disabled at:
[<ffff800010c5d50c>] spin_lock include/linux/spinlock.h:351 [inline]
[<ffff800010c5d50c>] sco_conn_ready net/bluetooth/sco.c:1297 [inline]
[<ffff800010c5d50c>] sco_connect_cfm+0x25c/0x8fc net/bluetooth/sco.c:1382
CPU: 0 PID: 4396 Comm: kworker/u5:2 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/03/2025
Workqueue: hci1 hci_rx_work
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack+0x30/0x40 lib/dump_stack.c:88
 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106
 dump_stack+0x1c/0x5c lib/dump_stack.c:113
 __might_resched+0x350/0x4cc kernel/sched/core.c:9966
 __might_sleep+0x94/0x110 kernel/sched/core.c:9895
 lock_sock_nested+0x80/0x130 net/core/sock.c:3495
 lock_sock include/net/sock.h:1792 [inline]
 sco_conn_ready net/bluetooth/sco.c:1310 [inline]
 sco_connect_cfm+0x3cc/0x8fc net/bluetooth/sco.c:1382
 hci_connect_cfm include/net/bluetooth/hci_core.h:1808 [inline]
 hci_sync_conn_complete_evt+0x460/0x90c net/bluetooth/hci_event.c:5104
 hci_event_func net/bluetooth/hci_event.c:7381 [inline]
 hci_event_packet+0x6f4/0xf08 net/bluetooth/hci_event.c:7433
 hci_rx_work+0x324/0xaa0 net/bluetooth/hci_core.c:4083
 process_one_work+0x7f4/0x13a8 kernel/workqueue.c:2292
 worker_thread+0x8c8/0xfbc kernel/workqueue.c:2439
 kthread+0x250/0x2d8 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0xf0/0x6544 kernel/locking/lockdep.c:4919
Read of size 8 at addr ffff0000efde10b0 by task kworker/u5:2/4396

CPU: 0 PID: 4396 Comm: kworker/u5:2 Tainted: G        W          syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/03/2025
Workqueue: hci1 hci_rx_work
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack+0x30/0x40 lib/dump_stack.c:88
 dump_stack_lvl+0xf8/0x160 lib/dump_stack.c:106
 print_address_description+0x88/0x218 mm/kasan/report.c:316
 print_report+0x50/0x68 mm/kasan/report.c:420
 kasan_report+0xa8/0x100 mm/kasan/report.c:524
 __asan_report_load8_noabort+0x2c/0x38 mm/kasan/report_generic.c:351
 __lock_acquire+0xf0/0x6544 kernel/locking/lockdep.c:4919
 lock_acquire+0x20c/0x644 kernel/locking/lockdep.c:5662
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
 _raw_spin_lock_bh+0x54/0x6c kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:356 [inline]
 lock_sock_nested+0x88/0x130 net/core/sock.c:3496
 lock_sock include/net/sock.h:1792 [inline]
 sco_conn_ready net/bluetooth/sco.c:1310 [inline]
 sco_connect_cfm+0x3cc/0x8fc net/bluetooth/sco.c:1382
 hci_connect_cfm include/net/bluetooth/hci_core.h:1808 [inline]
 hci_sync_conn_complete_evt+0x460/0x90c net/bluetooth/hci_event.c:5104
 hci_event_func net/bluetooth/hci_event.c:7381 [inline]
 hci_event_packet+0x6f4/0xf08 net/bluetooth/hci_event.c:7433
 hci_rx_work+0x324/0xaa0 net/bluetooth/hci_core.c:4083
 process_one_work+0x7f4/0x13a8 kernel/workqueue.c:2292
 worker_thread+0x8c8/0xfbc kernel/workqueue.c:2439
 kthread+0x250/0x2d8 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850

Allocated by task 4548:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_alloc_info+0x28/0x34 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0xa0/0xb8 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:936 [inline]
 __kmalloc+0xec/0x178 mm/slab_common.c:949
 kmalloc include/linux/slab.h:568 [inline]
 sk_prot_alloc+0xc4/0x1f0 net/core/sock.c:2052
 sk_alloc+0x44/0x390 net/core/sock.c:2108
 bt_sock_alloc+0x4c/0x140 net/bluetooth/af_bluetooth.c:148
 sco_sock_alloc net/bluetooth/sco.c:520 [inline]
 sco_sock_create+0xbc/0x338 net/bluetooth/sco.c:551
 bt_sock_create+0x14c/0x24c net/bluetooth/af_bluetooth.c:132
 __sock_create+0x4b0/0x8b4 net/socket.c:1550
 sock_create net/socket.c:1606 [inline]
 __sys_socket_create net/socket.c:1643 [inline]
 __sys_socket+0xc0/0x1ac net/socket.c:1671
 __do_sys_socket net/socket.c:1684 [inline]
 __se_sys_socket net/socket.c:1682 [inline]
 __arm64_sys_socket+0x7c/0x94 net/socket.c:1682
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2bc arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x58/0x13c arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x138 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Freed by task 4548:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_free_info+0x3c/0x60 mm/kasan/generic.c:516
 ____kasan_slab_free+0x148/0x1b0 mm/kasan/common.c:236
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1729 [inline]
 slab_free_freelist_hook+0x16c/0x1ec mm/slub.c:1755
 slab_free mm/slub.c:3687 [inline]
 __kmem_cache_free+0xc0/0x224 mm/slub.c:3700
 kfree+0xd0/0x1ac mm/slab_common.c:988
 sk_prot_free net/core/sock.c:2091 [inline]
 __sk_destruct+0x4dc/0x780 net/core/sock.c:2177
 sk_destruct net/core/sock.c:2192 [inline]
 __sk_free+0x320/0x430 net/core/sock.c:2203
 sk_free+0x60/0xc8 net/core/sock.c:2214
 sock_put include/net/sock.h:2072 [inline]
 sco_sock_kill+0xfc/0x1b4 net/bluetooth/sco.c:440
 sco_sock_release+0x1f8/0x2c4 net/bluetooth/sco.c:1279
 __sock_release net/socket.c:654 [inline]
 sock_close+0xb4/0x1f8 net/socket.c:1400
 __fput+0x1bc/0x7c0 fs/file_table.c:320
 ____fput+0x20/0x30 fs/file_table.c:348
 task_work_run+0x1ec/0x270 kernel/task_work.c:203
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 do_notify_resume+0x2038/0x2b28 arch/arm64/kernel/signal.c:1137
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
 el0_svc+0x98/0x138 arch/arm64/kernel/entry-common.c:638
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

The buggy address belongs to the object at ffff0000efde1000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 176 bytes inside of
 2048-byte region [ffff0000efde1000, ffff0000efde1800)

The buggy address belongs to the physical page:
page:00000000282507d7 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12fde0
head:00000000282507d7 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 0000000000000000 dead000000000122 ffff0000c0002900
raw: 0000000000000000 0000000080080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000efde0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000efde1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000efde1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff0000efde1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000efde1180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Unable to handle kernel paging request at virtual address dfff800000000000
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
Mem abort info:
  ESR = 0x0000000096000006
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x06: level 2 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000006
  CM = 0, WnR = 0
[dfff800000000000] address between user and kernel address ranges
Internal error: Oops: 0000000096000006 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 4396 Comm: kworker/u5:2 Tainted: G    B   W          syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/03/2025
Workqueue: hci1 hci_rx_work
pstate: 82400005 (Nzcv daif +PAN -UAO +TCO -DIT -SSBS BTYPE=--)
pc : apparmor_sk_clone_security+0xec/0x398 security/apparmor/lsm.c:845
lr : apparmor_sk_clone_security+0xcc/0x398 security/apparmor/lsm.c:843
sp : ffff800020d37780
x29: ffff800020d37780 x28: 1fffe0001936d809 x27: 1ffff000041a6f04
x26: dfff800000000000 x25: 0000000000000005 x24: 1fffe0001b5d28a0
x23: dfff800000000000 x22: dfff800000000000 x21: 0000000000000000
x20: 0000000000000000 x19: ffff0000dae94500 x18: 0000000059717912
x17: ffff800008205f1c x16: ffff8000082e8848 x15: ffff800010b54188
x14: ffff800010b712e0 x13: ffff80000802a690 x12: 0000000000ff0100
x11: ff0080000a5126e0 x10: 0000000000000000 x9 : ffff80000a5126e0
x8 : 0000000000000000 x7 : ffffffffffffffff x6 : ffff800010b4171c
x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff80000a51265c
x2 : 0000000000000000 x1 : 0000000000000008 x0 : 0000000000000000
Call trace:
 apparmor_sk_clone_security+0xec/0x398 security/apparmor/lsm.c:845
 security_sk_clone+0x58/0x9c security/security.c:2341
 sco_sock_init net/bluetooth/sco.c:503 [inline]
 sco_conn_ready net/bluetooth/sco.c:1320 [inline]
 sco_connect_cfm+0x564/0x8fc net/bluetooth/sco.c:1382
 hci_connect_cfm include/net/bluetooth/hci_core.h:1808 [inline]
 hci_sync_conn_complete_evt+0x460/0x90c net/bluetooth/hci_event.c:5104
 hci_event_func net/bluetooth/hci_event.c:7381 [inline]
 hci_event_packet+0x6f4/0xf08 net/bluetooth/hci_event.c:7433
 hci_rx_work+0x324/0xaa0 net/bluetooth/hci_core.c:4083
 process_one_work+0x7f4/0x13a8 kernel/workqueue.c:2292
 worker_thread+0x8c8/0xfbc kernel/workqueue.c:2439
 kthread+0x250/0x2d8 kernel/kthread.c:376
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:850
Code: 710006df 5400104b 977e3d62 d343fe88 (38776908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	710006df 	cmp	w22, #0x1
   4:	5400104b 	b.lt	0x20c  // b.tstop
   8:	977e3d62 	bl	0xfffffffffdf8f590
   c:	d343fe88 	lsr	x8, x20, #3
* 10:	38776908 	ldrb	w8, [x8, x23] <-- trapping instruction

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/11/12 01:05 linux-6.1.y f6e38ae624cf 4e1406b4 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
2025/02/23 05:28 linux-6.1.y 3a8358583626 d34966d1 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
2025/02/23 04:08 linux-6.1.y 3a8358583626 d34966d1 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
2025/02/23 03:06 linux-6.1.y 3a8358583626 d34966d1 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
2025/02/23 01:59 linux-6.1.y 3a8358583626 d34966d1 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
2025/08/03 21:32 linux-6.1.y 3594f306da12 7368264b .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf KASAN: use-after-free Write in lock_sock_nested
2025/08/19 21:50 linux-6.1.y 0bc96de781b4 254a27c1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan BUG: sleeping function called from invalid context in lock_sock_nested
2025/02/23 00:56 linux-6.1.y 3a8358583626 d34966d1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: sleeping function called from invalid context in lock_sock_nested
* Struck through repros no longer work on HEAD.