syzbot


KASAN: use-after-free Read in inet_twsk_purge

Status: premoderation: reported on 2025/06/08 04:39
Reported-by: syzbot+bd18e2ecb9e7a42a5845@syzkaller.appspotmail.com
First crash: 9d07h, last: 9h18m
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Read in inet_twsk_purge 36 47m 10d 0/2 premoderation: reported on 2025/06/06 21:54
linux-4.14 KASAN: use-after-free Read in inet_twsk_purge (2) 2 1538d 1574d 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 2024d 2123d 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/linux/atomic/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+0x223/0x670 net/ipv4/inet_timewait_sock.c:278
Read of size 4 at addr ffff88811ee7708c by task kworker/u4:4/329

CPU: 0 PID: 329 Comm: kworker/u4:4 Tainted: G        W         5.15.185-syzkaller-00339-ge678c93d43cc #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Workqueue: netns cleanup_net
Call Trace:
 <TASK>
 __dump_stack+0x21/0x30 lib/dump_stack.c:88
 dump_stack_lvl+0xee/0x150 lib/dump_stack.c:106
 print_address_description+0x7f/0x2c0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0xf1/0x140 mm/kasan/report.c:444
 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/linux/atomic/atomic-instrumented.h:27 [inline]
 refcount_read include/linux/refcount.h:147 [inline]
 inet_twsk_purge+0x223/0x670 net/ipv4/inet_timewait_sock.c:278
 tcpv6_net_exit_batch+0x1a/0x20 net/ipv6/tcp_ipv6.c:2229
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x602/0xad0 net/core/net_namespace.c:599
 process_one_work+0x6be/0xba0 kernel/workqueue.c:2325
 worker_thread+0xa59/0x1200 kernel/workqueue.c:2472
 kthread+0x411/0x500 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 281:
 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:433 [inline]
 __kasan_slab_alloc+0xbd/0xf0 mm/kasan/common.c:466
 kasan_slab_alloc include/linux/kasan.h:217 [inline]
 slab_post_alloc_hook+0x4f/0x2b0 mm/slab.h:550
 slab_alloc_node mm/slub.c:3240 [inline]
 slab_alloc mm/slub.c:3250 [inline]
 kmem_cache_alloc+0xf7/0x260 mm/slub.c:3255
 kmem_cache_zalloc include/linux/slab.h:737 [inline]
 net_alloc net/core/net_namespace.c:408 [inline]
 copy_net_ns+0x145/0x5c0 net/core/net_namespace.c:463
 create_new_namespaces+0x3a2/0x660 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x4ac/0x7b0 kernel/fork.c:3242
 __do_sys_unshare kernel/fork.c:3316 [inline]
 __se_sys_unshare kernel/fork.c:3314 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3314
 x64_sys_call+0x442/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
 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 329:
 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:365
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
 kasan_slab_free include/linux/kasan.h:193 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0xc2/0x190 mm/slub.c:1749
 slab_free mm/slub.c:3521 [inline]
 kmem_cache_free+0x100/0x320 mm/slub.c:3539
 net_free net/core/net_namespace.c:437 [inline]
 cleanup_net+0xa2d/0xad0 net/core/net_namespace.c:620
 process_one_work+0x6be/0xba0 kernel/workqueue.c:2325
 worker_thread+0xa59/0x1200 kernel/workqueue.c:2472
 kthread+0x411/0x500 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

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+0x51/0x310 kernel/workqueue.c:1373
 __queue_work+0x8e5/0xc60 kernel/workqueue.c:1539
 queue_work_on+0xd2/0x140 kernel/workqueue.c:1566
 queue_work include/linux/workqueue.h:510 [inline]
 schedule_work include/linux/workqueue.h:571 [inline]
 xfrm_policy_hash_rebuild+0x4f/0x60 net/xfrm/xfrm_policy.c:1366
 xfrm_set_spdinfo+0x3f6/0x5e0 net/xfrm/xfrm_user.c:1345
 xfrm_user_rcv_msg+0x45c/0x6e0 net/xfrm/xfrm_user.c:2981
 netlink_rcv_skb+0x1e0/0x430 net/netlink/af_netlink.c:2493
 xfrm_netlink_rcv+0x72/0x90 net/xfrm/xfrm_user.c:3003
 netlink_unicast_kernel net/netlink/af_netlink.c:1315 [inline]
 netlink_unicast+0x87c/0xa40 net/netlink/af_netlink.c:1341
 netlink_sendmsg+0x86a/0xb70 net/netlink/af_netlink.c:1909
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x5a2/0x8c0 net/socket.c:2436
 ___sys_sendmsg+0x1f0/0x260 net/socket.c:2490
 __sys_sendmsg net/socket.c:2519 [inline]
 __do_sys_sendmsg net/socket.c:2528 [inline]
 __se_sys_sendmsg net/socket.c:2526 [inline]
 __x64_sys_sendmsg+0x1e2/0x2a0 net/socket.c:2526
 x64_sys_call+0x4b/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:47
 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 ffff88811ee77000
 which belongs to the cache net_namespace of size 3968
The buggy address is located 140 bytes inside of
 3968-byte region [ffff88811ee77000, ffff88811ee77f80)
The buggy address belongs to the page:
page:ffffea00047b9c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11ee70
head:ffffea00047b9c00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea00047fe800 0000000200000002 ffff8881001c4480
raw: 0000000000000000 0000000000080008 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 281, ts 23093899202, free_ts 23017911348
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x192/0x1b0 mm/page_alloc.c:2605
 prep_new_page+0x1c/0x110 mm/page_alloc.c:2611
 get_page_from_freelist+0x2cc5/0x2d50 mm/page_alloc.c:4485
 __alloc_pages+0x18f/0x440 mm/page_alloc.c:5789
 alloc_slab_page mm/slub.c:-1 [inline]
 allocate_slab mm/slub.c:1932 [inline]
 new_slab+0xa1/0x4d0 mm/slub.c:1995
 ___slab_alloc+0x381/0x810 mm/slub.c:3028
 __slab_alloc+0x49/0x90 mm/slub.c:3115
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3250 [inline]
 kmem_cache_alloc+0x138/0x260 mm/slub.c:3255
 kmem_cache_zalloc include/linux/slab.h:737 [inline]
 net_alloc net/core/net_namespace.c:408 [inline]
 copy_net_ns+0x145/0x5c0 net/core/net_namespace.c:463
 create_new_namespaces+0x3a2/0x660 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x120/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x4ac/0x7b0 kernel/fork.c:3242
 __do_sys_unshare kernel/fork.c:3316 [inline]
 __se_sys_unshare kernel/fork.c:3314 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3314
 x64_sys_call+0x442/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
 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:26 [inline]
 free_pages_prepare mm/page_alloc.c:1472 [inline]
 free_pcp_prepare mm/page_alloc.c:1544 [inline]
 free_unref_page_prepare+0x542/0x550 mm/page_alloc.c:3534
 free_unref_page+0xa2/0x550 mm/page_alloc.c:3616
 free_the_page mm/page_alloc.c:805 [inline]
 free_compound_page+0x78/0xa0 mm/page_alloc.c:828
 destroy_compound_page include/linux/mm.h:989 [inline]
 __put_compound_page+0x77/0xb0 mm/swap.c:111
 __put_page+0xbc/0xe0 mm/swap.c:127
 put_page include/linux/mm.h:1295 [inline]
 __skb_frag_unref include/linux/skbuff.h:3252 [inline]
 skb_release_data+0x3d3/0xa10 net/core/skbuff.c:673
 skb_release_all net/core/skbuff.c:743 [inline]
 __kfree_skb+0x50/0x70 net/core/skbuff.c:757
 sk_eat_skb include/net/sock.h:2750 [inline]
 tcp_recvmsg_locked+0x14ac/0x2640 net/ipv4/tcp.c:2517
 tcp_recvmsg+0x21b/0x720 net/ipv4/tcp.c:2563
 inet_recvmsg+0x134/0x470 net/ipv4/af_inet.c:861
 sock_recvmsg_nosec net/socket.c:966 [inline]
 sock_recvmsg net/socket.c:984 [inline]
 sock_read_iter+0x2a2/0x340 net/socket.c:1057
 call_read_iter include/linux/fs.h:2198 [inline]
 new_sync_read fs/read_write.c:404 [inline]
 vfs_read+0x68b/0xbe0 fs/read_write.c:485
 ksys_read+0x140/0x240 fs/read_write.c:623
 __do_sys_read fs/read_write.c:633 [inline]
 __se_sys_read fs/read_write.c:631 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:631
 x64_sys_call+0x96d/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:1
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80

Memory state around the buggy address:
 ffff88811ee76f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811ee77000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88811ee77080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88811ee77100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811ee77180: 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/17 02:59 android13-5.15-lts e678c93d43cc cfebc887 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in inet_twsk_purge
2025/06/16 10:23 android13-5.15-lts e678c93d43cc 5f4b362d .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in inet_twsk_purge
2025/06/09 14:23 android13-5.15-lts e678c93d43cc 4826c28e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in inet_twsk_purge
2025/06/09 00:00 android13-5.15-lts e678c93d43cc 4826c28e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in inet_twsk_purge
2025/06/08 04:38 android13-5.15-lts e678c93d43cc 4826c28e .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Read in inet_twsk_purge
* Struck through repros no longer work on HEAD.