syzbot


KASAN: use-after-free Read in inet_twsk_purge

Status: premoderation: reported on 2025/06/06 21:54
Reported-by: syzbot+f9ca9cf446af5c78ed52@syzkaller.appspotmail.com
First crash: 1d08h, last: 17h34m
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Read in inet_twsk_purge 1 1h31m 1h30m 0/2 premoderation: reported on 2025/06/08 04:39
linux-4.14 KASAN: use-after-free Read in inet_twsk_purge (2) 2 1529d 1564d 0/1 auto-closed as invalid on 2021/07/30 01:43
linux-4.14 KASAN: use-after-free Read in inet_twsk_purge 3 2014d 2114d 0/1 auto-closed as invalid on 2020/03/31 12:08

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:147 [inline]
BUG: KASAN: use-after-free in inet_twsk_purge+0x1fe/0x620 net/ipv4/inet_timewait_sock.c:278
Read of size 4 at addr ffff88811e258004 by task syz.5.6039/19918

CPU: 0 PID: 19918 Comm: syz.5.6039 Tainted: G        W         5.10.238-syzkaller-00282-gd76d4cd0623a #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 __dump_stack+0x21/0x24 lib/dump_stack.c:77
 dump_stack_lvl+0x169/0x1d8 lib/dump_stack.c:118
 print_address_description+0x7f/0x2c0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0xe2/0x130 mm/kasan/report.c:452
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x280/0x290 mm/kasan/generic.c:189
 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 atomic_read include/asm-generic/atomic-instrumented.h:27 [inline]
 refcount_read include/linux/refcount.h:147 [inline]
 inet_twsk_purge+0x1fe/0x620 net/ipv4/inet_timewait_sock.c:278
 tcpv6_net_exit_batch+0x1a/0x20 net/ipv6/tcp_ipv6.c:2194
 ops_exit_list net/core/net_namespace.c:190 [inline]
 setup_net+0x788/0xb50 net/core/net_namespace.c:368
 copy_net_ns+0x314/0x520 net/core/net_namespace.c:486
 create_new_namespaces+0x3a2/0x650 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:231
 ksys_unshare+0x4ac/0x7d0 kernel/fork.c:3156
 __do_sys_unshare kernel/fork.c:3224 [inline]
 __se_sys_unshare kernel/fork.c:3222 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3222
 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fcaef9d9929
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fcaee021038 EFLAGS: 00000246 ORIG_RAX: 0000000000000110
RAX: ffffffffffffffda RBX: 00007fcaefc01080 RCX: 00007fcaef9d9929
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000040000200
RBP: 00007fcaefa5bb39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fcaefc01080 R15: 00007ffc1f822cb8

Allocated by task 9884:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 __kasan_slab_alloc+0xbd/0xf0 mm/kasan/common.c:463
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x5d/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x165/0x2e0 mm/slub.c:2960
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 net_alloc net/core/net_namespace.c:421 [inline]
 copy_net_ns+0x13f/0x520 net/core/net_namespace.c:473
 create_new_namespaces+0x3a2/0x650 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:231
 ksys_unshare+0x4ac/0x7d0 kernel/fork.c:3156
 __do_sys_unshare kernel/fork.c:3224 [inline]
 __se_sys_unshare kernel/fork.c:3222 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3222
 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 5788:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4a/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x125/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc5/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kmem_cache_free+0x100/0x2d0 mm/slub.c:3219
 net_free net/core/net_namespace.c:449 [inline]
 net_drop_ns net/core/net_namespace.c:456 [inline]
 cleanup_net+0xae3/0xb70 net/core/net_namespace.c:630
 process_one_work+0x6e1/0xba0 kernel/workqueue.c:2301
 worker_thread+0xa6a/0x13b0 kernel/workqueue.c:2447
 kthread+0x346/0x3d0 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd2/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 insert_work+0x52/0x310 kernel/workqueue.c:1352
 __queue_work+0x923/0xca0 kernel/workqueue.c:1518
 queue_work_on+0xd5/0x130 kernel/workqueue.c:1545
 queue_work include/linux/workqueue.h:515 [inline]
 schedule_work include/linux/workqueue.h:576 [inline]
 xfrm_hash_grow_check+0xd7/0x140 net/xfrm/xfrm_state.c:1000
 xfrm_state_find+0x24e8/0x2880 net/xfrm/xfrm_state.c:1156
 xfrm_tmpl_resolve_one net/xfrm/xfrm_policy.c:2398 [inline]
 xfrm_tmpl_resolve net/xfrm/xfrm_policy.c:2443 [inline]
 xfrm_resolve_and_create_bundle+0x626/0x28d0 net/xfrm/xfrm_policy.c:2736
 xfrm_lookup_with_ifid+0x8eb/0x1980 net/xfrm/xfrm_policy.c:3070
 xfrm_lookup net/xfrm/xfrm_policy.c:3194 [inline]
 xfrm_lookup_route+0x3c/0x170 net/xfrm/xfrm_policy.c:3205
 ip_route_output_flow+0x1d2/0x2d0 net/ipv4/route.c:2796
 udp_sendmsg+0x121f/0x2080 net/ipv4/udp.c:1231
 inet_sendmsg+0xa5/0xc0 net/ipv4/af_inet.c:830
 sock_sendmsg_nosec net/socket.c:652 [inline]
 __sock_sendmsg net/socket.c:664 [inline]
 ____sys_sendmsg+0x5a2/0x8c0 net/socket.c:2376
 ___sys_sendmsg+0x1f0/0x260 net/socket.c:2430
 __sys_sendmmsg+0x273/0x450 net/socket.c:2516
 __do_sys_sendmmsg net/socket.c:2545 [inline]
 __se_sys_sendmmsg net/socket.c:2542 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2542
 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x3a/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd2/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 insert_work+0x52/0x310 kernel/workqueue.c:1352
 __queue_work+0x923/0xca0 kernel/workqueue.c:1518
 queue_work_on+0xd5/0x130 kernel/workqueue.c:1545
 queue_work include/linux/workqueue.h:515 [inline]
 schedule_work include/linux/workqueue.h:576 [inline]
 xfrm_hash_grow_check+0xd7/0x140 net/xfrm/xfrm_state.c:1000
 xfrm_state_find+0x24e8/0x2880 net/xfrm/xfrm_state.c:1156
 xfrm_tmpl_resolve_one net/xfrm/xfrm_policy.c:2398 [inline]
 xfrm_tmpl_resolve net/xfrm/xfrm_policy.c:2443 [inline]
 xfrm_resolve_and_create_bundle+0x626/0x28d0 net/xfrm/xfrm_policy.c:2736
 xfrm_lookup_with_ifid+0x8eb/0x1980 net/xfrm/xfrm_policy.c:3070
 xfrm_lookup net/xfrm/xfrm_policy.c:3194 [inline]
 xfrm_lookup_route+0x3c/0x170 net/xfrm/xfrm_policy.c:3205
 ip_route_output_flow+0x1d2/0x2d0 net/ipv4/route.c:2796
 udp_sendmsg+0x121f/0x2080 net/ipv4/udp.c:1231
 inet_sendmsg+0xa5/0xc0 net/ipv4/af_inet.c:830
 sock_sendmsg_nosec net/socket.c:652 [inline]
 __sock_sendmsg net/socket.c:664 [inline]
 ____sys_sendmsg+0x5a2/0x8c0 net/socket.c:2376
 ___sys_sendmsg+0x1f0/0x260 net/socket.c:2430
 __sys_sendmmsg+0x273/0x450 net/socket.c:2516
 __do_sys_sendmmsg net/socket.c:2545 [inline]
 __se_sys_sendmmsg net/socket.c:2542 [inline]
 __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2542
 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff88811e258000
 which belongs to the cache net_namespace of size 4672
The buggy address is located 4 bytes inside of
 4672-byte region [ffff88811e258000, ffff88811e259240)
The buggy address belongs to the page:
page:ffffea0004789600 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88811e259340 pfn:0x11e258
head:ffffea0004789600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 ffffea0004921a08 ffff888107fa7a10 ffff888107fddb00
raw: ffff88811e259340 0000000000060001 00000001ffffffff 0000000000000000
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 6423, ts 422523434062, free_ts 422320268439
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x179/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2235/0x23d0 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x268/0x5f0 mm/page_alloc.c:5357
 alloc_slab_page mm/slub.c:-1 [inline]
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x84/0x3f0 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x2a6/0x450 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x1af/0x2e0 mm/slub.c:2960
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 net_alloc net/core/net_namespace.c:421 [inline]
 copy_net_ns+0x13f/0x520 net/core/net_namespace.c:473
 create_new_namespaces+0x3a2/0x650 kernel/nsproxy.c:110
 copy_namespaces+0x1d1/0x220 kernel/nsproxy.c:179
 copy_process+0x11b8/0x32c0 kernel/fork.c:2271
 kernel_clone+0x23f/0x940 kernel/fork.c:2650
 __do_sys_clone3 kernel/fork.c:2934 [inline]
 __se_sys_clone3 kernel/fork.c:2918 [inline]
 __x64_sys_clone3+0x296/0x2f0 kernel/fork.c:2918
 do_syscall_64+0x31/0x40 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 __free_pages_ok+0x7fc/0x820 mm/page_alloc.c:1629
 free_compound_page+0x73/0x90 mm/page_alloc.c:710
 destroy_compound_page include/linux/mm.h:959 [inline]
 __put_compound_page+0x77/0xb0 mm/swap.c:117
 __put_page+0xbd/0xe0 mm/swap.c:133
 put_page include/linux/mm.h:1257 [inline]
 do_exit+0x1a32/0x2470 kernel/exit.c:902
 do_group_exit+0x141/0x310 kernel/exit.c:985
 get_signal+0xf7d/0x12e0 kernel/signal.c:2793
 arch_do_signal_or_restart+0xbf/0x10f0 arch/x86/kernel/signal.c:805
 handle_signal_work kernel/entry/common.c:145 [inline]
 exit_to_user_mode_loop+0xa2/0xe0 kernel/entry/common.c:169
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0x68/0x90 kernel/entry/common.c:274
 do_syscall_64+0x3d/0x40 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff88811e257f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88811e257f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88811e258000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88811e258080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811e258100: 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/06/07 12:35 android13-5.10-lts d76d4cd0623a 4826c28e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in inet_twsk_purge
2025/06/06 23:32 android13-5.10-lts d76d4cd0623a 9fa58bba .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in inet_twsk_purge
2025/06/06 23:30 android13-5.10-lts d76d4cd0623a 9fa58bba .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in inet_twsk_purge
2025/06/06 23:21 android13-5.10-lts d76d4cd0623a 9fa58bba .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in inet_twsk_purge
2025/06/06 21:53 android13-5.10-lts d76d4cd0623a 9fa58bba .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in inet_twsk_purge
* Struck through repros no longer work on HEAD.