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: 1d13h, last: 3h22m
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 9 9h55m 2d19h 0/2 premoderation: reported on 2025/06/06 21:54
linux-4.14 KASAN: use-after-free Read in inet_twsk_purge (2) 2 1530d 1566d 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 2016d 2115d 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 ffff888120efc08c by task kworker/u4:6/450

CPU: 0 PID: 450 Comm: kworker/u4:6 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 3048:
 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 450:
 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

The buggy address belongs to the object at ffff888120efc000
 which belongs to the cache net_namespace of size 3968
The buggy address is located 140 bytes inside of
 3968-byte region [ffff888120efc000, ffff888120efcf80)
The buggy address belongs to the page:
page:ffffea000483be00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888120efe000 pfn:0x120ef8
head:ffffea000483be00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea00041e6400 0000000200000002 ffff8881001c4780
raw: ffff888120efe000 0000000080080001 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 1793, ts 104409838217, free_ts 102613733479
 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_pages+0x6c/0x100 mm/page_alloc.c:5865
 __free_slab+0xe8/0x1e0 mm/slub.c:2020
 free_slab mm/slub.c:2035 [inline]
 discard_slab mm/slub.c:2041 [inline]
 __unfreeze_partials+0x160/0x190 mm/slub.c:2527
 put_cpu_partial+0xc6/0x120 mm/slub.c:2607
 __slab_free+0x1d4/0x290 mm/slub.c:3390
 do_slab_free mm/slub.c:3509 [inline]
 ___cache_free+0x104/0x120 mm/slub.c:3530
 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x5f/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x14a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xf0 mm/kasan/common.c:443
 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_alloc_node include/linux/slab.h:489 [inline]
 __alloc_skb+0xe0/0x740 net/core/skbuff.c:416
 alloc_skb include/linux/skbuff.h:1183 [inline]
 nlmsg_new include/net/netlink.h:953 [inline]
 inet6_netconf_notify_devconf+0xd6/0x190 net/ipv6/addrconf.c:583

Memory state around the buggy address:
 ffff888120efbf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888120efc000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888120efc080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888120efc100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888120efc180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
tipc: Left network mode
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
bridge0: port 1(bridge_slave_0) entered disabled state
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.