syzbot


KASAN: use-after-free Read in __lock_sock (3)

Status: upstream: reported C repro on 2025/07/23 10:25
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+f905ba9e11def6007fca@syzkaller.appspotmail.com
First crash: 13d, last: 13d
Bug presence (1)
Date Name Commit Repro Result
2025/07/24 upstream (ToT) 25fae0b93d1d 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 2454d 20/29 fixed on 2022/03/08 16:11
linux-4.19 KASAN: use-after-free Read in __lock_sock (2) 19 1 2012d 2012d 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 1883d 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-6.1 KASAN: use-after-free Read in __lock_sock origin:upstream 19 C 1 3d03h 3d03h 0/3 upstream: reported C repro on 2025/08/03 04:51
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 8d22h 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/0x7c60 kernel/locking/lockdep.c:4882
Read of size 8 at addr ffff8880757541e0 by task kworker/u4:2/154

CPU: 0 PID: 154 Comm: kworker/u4:2 Not tainted 5.15.189-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Workqueue: kkcmd kcm_tx_work
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106
 print_address_description+0x60/0x2d0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0xdf/0x130 mm/kasan/report.c:451
 __lock_acquire+0xf7/0x7c60 kernel/locking/lockdep.c:4882
 lock_acquire+0x197/0x3f0 kernel/locking/lockdep.c:5623
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x32/0x50 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:368 [inline]
 __lock_sock+0x152/0x2a0 net/core/sock.c:2702
 lock_sock_nested+0x9d/0x100 net/core/sock.c:3256
 lock_sock include/net/sock.h:1694 [inline]
 kcm_tx_work+0x2d/0x180 net/kcm/kcmsock.c:730
 process_one_work+0x863/0x1000 kernel/workqueue.c:2310
 worker_thread+0xaa8/0x12a0 kernel/workqueue.c:2457
 kthread+0x436/0x520 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 4343:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x9c/0xd0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x4c/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x100/0x290 mm/slub.c:3233
 sk_prot_alloc+0x57/0x210 net/core/sock.c:1858
 sk_alloc+0x2f/0x310 net/core/sock.c:1917
 kcm_clone net/kcm/kcmsock.c:1641 [inline]
 kcm_ioctl+0x211/0xff0 net/kcm/kcmsock.c:1686
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1140
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1257
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 4344:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd5/0x110 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xea/0x170 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x8f/0x210 mm/slub.c:3515
 sk_prot_free net/core/sock.c:1898 [inline]
 __sk_destruct+0x54b/0x820 net/core/sock.c:1986
 kcm_release+0x51a/0x5b0 net/kcm/kcmsock.c:1861
 __sock_release net/socket.c:649 [inline]
 sock_close+0xd5/0x240 net/socket.c:1336
 __fput+0x234/0x930 fs/file_table.c:311
 task_work_run+0x125/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Last potentially related work creation:
 kasan_save_stack+0x35/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xb8/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3d0 kernel/workqueue.c:1366
 __queue_work+0x9c5/0xd50 kernel/workqueue.c:1532
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1559
 queue_work include/linux/workqueue.h:512 [inline]
 kcm_unattach+0x85e/0xe80 net/kcm/kcmsock.c:1550
 kcm_unattach_ioctl net/kcm/kcmsock.c:1607 [inline]
 kcm_ioctl+0x78d/0xff0 net/kcm/kcmsock.c:1674
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1140
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1257
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Second to last potentially related work creation:
 kasan_save_stack+0x35/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xb8/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3d0 kernel/workqueue.c:1366
 __queue_work+0x9c5/0xd50 kernel/workqueue.c:1532
 queue_work_on+0x11d/0x1d0 kernel/workqueue.c:1559
 kcm_attach net/kcm/kcmsock.c:1430 [inline]
 kcm_attach_ioctl net/kcm/kcmsock.c:1458 [inline]
 kcm_ioctl+0xe4b/0xff0 net/kcm/kcmsock.c:1664
 sock_do_ioctl+0xd3/0x2f0 net/socket.c:1140
 sock_ioctl+0x4ed/0x6e0 net/socket.c:1257
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xfa/0x170 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888075754140
 which belongs to the cache KCM of size 1728
The buggy address is located 160 bytes inside of
 1728-byte region [ffff888075754140, ffff888075754800)
The buggy address belongs to the page:
page:ffffea0001d5d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x75750
head:ffffea0001d5d400 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff888025316201
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff88802a0d4780
raw: 0000000000000000 0000000080110011 00000001ffffffff ffff888025316201
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 4313, ts 78617223154, free_ts 78605532091
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x1b77/0x1c60 mm/page_alloc.c:4192
 __alloc_pages+0x1e1/0x470 mm/page_alloc.c:5474
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xc0/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x81e/0xdf0 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x195/0x290 mm/slub.c:3233
 sk_prot_alloc+0x57/0x210 net/core/sock.c:1858
 sk_alloc+0x2f/0x310 net/core/sock.c:1917
 kcm_create+0xfc/0x570 net/kcm/kcmsock.c:1931
 __sock_create+0x47b/0x900 net/socket.c:1486
 sock_create net/socket.c:1542 [inline]
 __sys_socket+0xe2/0x170 net/socket.c:1584
 __do_sys_socket net/socket.c:1593 [inline]
 __se_sys_socket net/socket.c:1591 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1591
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0x637/0x6c0 mm/page_alloc.c:3317
 free_unref_page+0x94/0x280 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1a5/0x200 mm/slub.c:2507
 put_cpu_partial+0x12d/0x190 mm/slub.c:2587
 qlist_free_all+0x35/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x150/0x160 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xd0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x4c/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x100/0x290 mm/slub.c:3233
 getname_flags+0xb5/0x500 fs/namei.c:138
 do_sys_openat2+0xcf/0x4a0 fs/open.c:1247
 do_sys_open fs/open.c:1269 [inline]
 __do_sys_openat fs/open.c:1285 [inline]
 __se_sys_openat fs/open.c:1280 [inline]
 __x64_sys_openat+0x135/0x160 fs/open.c:1280
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Memory state around the buggy address:
 ffff888075754080: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888075754100: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff888075754180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff888075754200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888075754280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/24 06:45 linux-5.15.y c79648372d02 0c1d6ded .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in __lock_sock
2025/07/24 05:00 linux-5.15.y c79648372d02 0c1d6ded .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in __lock_sock
2025/07/24 00:27 linux-5.15.y c79648372d02 0c1d6ded .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in __lock_sock
2025/07/23 16:44 linux-5.15.y c79648372d02 e1dd4f22 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in __lock_sock
2025/07/23 10:25 linux-5.15.y c79648372d02 e1dd4f22 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf KASAN: use-after-free Read in __lock_sock
* Struck through repros no longer work on HEAD.