syzbot


KASAN: use-after-free Read in __lock_sock

Status: upstream: reported C repro on 2025/08/03 04:51
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+b423ccad058be263094e@syzkaller.appspotmail.com
First crash: 3d00h, last: 3d00h
Bug presence (1)
Date Name Commit Repro Result
2025/08/05 upstream (ToT) 6bcdbd62bd56 C [report] KASAN: slab-use-after-free Read in __lock_sock
Similar bugs (11)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in __lock_sock 19 16 239d 305d 0/3 auto-obsoleted due to no activity on 2025/02/17 16:37
linux-4.19 KASAN: use-after-free Read in __lock_sock 19 syz done 2 2109d 2109d 1/1 fixed on 2019/12/18 04:11
upstream KASAN: use-after-free Read in __lock_sock sctp 19 syz done error 26 1638d 2453d 20/29 fixed on 2022/03/08 16:11
linux-4.19 KASAN: use-after-free Read in __lock_sock (2) 19 1 2011d 2011d 0/1 auto-closed as invalid on 2020/06/01 06:17
linux-4.14 KASAN: use-after-free Read in __lock_sock 19 syz inconclusive 1 1882d 2003d 0/1 upstream: reported syz repro on 2020/02/11 04:34
linux-5.15 KASAN: use-after-free Read in __lock_sock (2) 19 1 121d 121d 0/3 auto-obsoleted due to no activity on 2025/07/15 20:45
linux-5.15 KASAN: use-after-free Read in __lock_sock (3) origin:upstream 19 C 5 12d 13d 0/3 upstream: reported C repro on 2025/07/23 10:25
upstream KASAN: slab-use-after-free Read in __lock_sock bluetooth 19 C 1 622d 622d 0/29 auto-obsoleted due to no activity on 2024/03/01 14:18
linux-6.6 KASAN: slab-use-after-free Read in __lock_sock origin:upstream 19 C 6 14d 19d 0/2 upstream: reported C repro on 2025/07/17 21:41
upstream KASAN: slab-use-after-free Read in __lock_sock (2) bluetooth 19 C 5 401d 415d 0/29 auto-obsoleted due to no activity on 2024/10/08 16:07
upstream BUG: sleeping function called from invalid context in lock_sock_nested (3) bluetooth 19 C inconclusive error 152 8d19h 449d 0/29 upstream: reported C repro on 2024/05/13 12:58

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __lock_acquire+0xf7/0x7c50 kernel/locking/lockdep.c:4919
Read of size 8 at addr ffff8880691c00b0 by task kworker/u4:0/9

CPU: 1 PID: 9 Comm: kworker/u4:0 Not tainted 6.1.147-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Workqueue: kkcmd kcm_tx_work
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0xa8/0x200 mm/kasan/report.c:418
 kasan_report+0x10b/0x140 mm/kasan/report.c:522
 __lock_acquire+0xf7/0x7c50 kernel/locking/lockdep.c:4919
 lock_acquire+0x1b4/0x490 kernel/locking/lockdep.c:5662
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
 _raw_spin_lock_bh+0x32/0x50 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:356 [inline]
 __lock_sock+0x152/0x2a0 net/core/sock.c:2916
 lock_sock_nested+0x9b/0x100 net/core/sock.c:3493
 lock_sock include/net/sock.h:1756 [inline]
 kcm_tx_work+0x2d/0x180 net/kcm/kcmsock.c:731
 process_one_work+0x898/0x1160 kernel/workqueue.c:2292
 worker_thread+0xaa2/0x1250 kernel/workqueue.c:2439
 kthread+0x29d/0x330 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 4641:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x6b/0x80 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x4b/0x480 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x123/0x2f0 mm/slub.c:3422
 sk_prot_alloc+0x57/0x210 net/core/sock.c:2044
 sk_alloc+0x36/0x340 net/core/sock.c:2103
 kcm_clone net/kcm/kcmsock.c:1640 [inline]
 kcm_ioctl+0x211/0xff0 net/kcm/kcmsock.c:1685
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1204
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 4642:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2d/0x50 mm/kasan/generic.c:516
 ____kasan_slab_free+0x126/0x1e0 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x131/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0xf7/0x290 mm/slub.c:3683
 sk_prot_free net/core/sock.c:2084 [inline]
 __sk_destruct+0x48d/0x630 net/core/sock.c:2172
 kcm_release+0x520/0x5b0 net/kcm/kcmsock.c:1860
 __sock_release net/socket.c:654 [inline]
 sock_close+0xd5/0x240 net/socket.c:1400
 __fput+0x22c/0x920 fs/file_table.c:320
 task_work_run+0x1ca/0x250 kernel/task_work.c:203
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xe6/0x110 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:303
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3c0 kernel/workqueue.c:1361
 __queue_work+0xba3/0xfb0 kernel/workqueue.c:1520
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1548
 queue_work include/linux/workqueue.h:512 [inline]
 kcm_unattach+0x861/0xe80 net/kcm/kcmsock.c:1549
 kcm_unattach_ioctl net/kcm/kcmsock.c:1606 [inline]
 kcm_ioctl+0x78d/0xff0 net/kcm/kcmsock.c:1673
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1204
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Second to last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb2/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3c0 kernel/workqueue.c:1361
 __queue_work+0xba3/0xfb0 kernel/workqueue.c:1520
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1548
 kcm_attach net/kcm/kcmsock.c:1429 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1457 [inline]
 kcm_ioctl+0xe4b/0xff0 net/kcm/kcmsock.c:1663
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1204
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff8880691c0000
 which belongs to the cache KCM of size 1720
The buggy address is located 176 bytes inside of
 1720-byte region [ffff8880691c0000, ffff8880691c06b8)

The buggy address belongs to the physical page:
page:ffffea0001a47000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x691c0
head:ffffea0001a47000 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff888024240a01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff88814cc27640
raw: 0000000000000000 0000000080110011 00000001ffffffff ffff888024240a01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4641, tgid 4639 (syz.0.68), ts 135496927542, free_ts 85585135204
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x173/0x1a0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x1a26/0x1ac0 mm/page_alloc.c:4328
 __alloc_pages+0x1df/0x4e0 mm/page_alloc.c:5614
 alloc_slab_page+0x5d/0x160 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x87/0x2c0 mm/slub.c:1992
 ___slab_alloc+0xbc6/0x1220 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x1b7/0x2f0 mm/slub.c:3422
 sk_prot_alloc+0x57/0x210 net/core/sock.c:2044
 sk_alloc+0x36/0x340 net/core/sock.c:2103
 kcm_clone net/kcm/kcmsock.c:1640 [inline]
 kcm_ioctl+0x211/0xff0 net/kcm/kcmsock.c:1685
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1204
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x8b4/0x9a0 mm/page_alloc.c:3384
 free_unref_page+0x2e/0x3f0 mm/page_alloc.c:3479
 kasan_depopulate_vmalloc_pte+0x67/0x80 mm/kasan/shadow.c:375
 apply_to_pte_range mm/memory.c:2662 [inline]
 apply_to_pmd_range mm/memory.c:2706 [inline]
 apply_to_pud_range mm/memory.c:2742 [inline]
 apply_to_p4d_range mm/memory.c:2778 [inline]
 __apply_to_page_range+0x962/0xc80 mm/memory.c:2814
 kasan_release_vmalloc+0x93/0xb0 mm/kasan/shadow.c:492
 __purge_vmap_area_lazy+0xdb0/0x1900 mm/vmalloc.c:1782
 drain_vmap_area_work+0x3c/0xd0 mm/vmalloc.c:1811
 process_one_work+0x898/0x1160 kernel/workqueue.c:2292
 worker_thread+0xaa2/0x1250 kernel/workqueue.c:2439
 kthread+0x29d/0x330 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff8880691bff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880691c0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880691c0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffff8880691c0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880691c0180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/03 04:50 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 Read in __lock_sock
* Struck through repros no longer work on HEAD.