==================================================================
BUG: KASAN: use-after-free in inet_twsk_kill+0x62/0x670 net/ipv4/inet_timewait_sock.c:52
Read of size 8 at addr ffff8881109114c0 by task syz.0.3846/11538
CPU: 0 PID: 11538 Comm: syz.0.3846 Tainted: G W 6.1.141-syzkaller-00036-g7011769d221c #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:88
dump_stack_lvl+0xee/0x150 lib/dump_stack.c:106
print_address_description+0x71/0x210 mm/kasan/report.c:316
print_report+0x4a/0x60 mm/kasan/report.c:427
kasan_report+0x122/0x150 mm/kasan/report.c:531
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351
inet_twsk_kill+0x62/0x670 net/ipv4/inet_timewait_sock.c:52
tw_timer_handler+0x1c/0x20 net/ipv4/inet_timewait_sock.c:175
call_timer_fn+0x46/0x2a0 kernel/time/timer.c:1510
expire_timers kernel/time/timer.c:1555 [inline]
__run_timers+0x639/0x9a0 kernel/time/timer.c:1826
run_timer_softirq+0x6a/0xf0 kernel/time/timer.c:1839
handle_softirqs+0x1d7/0x600 kernel/softirq.c:642
__do_softirq kernel/softirq.c:680 [inline]
invoke_softirq kernel/softirq.c:497 [inline]
__irq_exit_rcu+0x52/0xf0 kernel/softirq.c:729
irq_exit_rcu+0x9/0x10 kernel/softirq.c:741
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
sysvec_apic_timer_interrupt+0xa9/0xc0 arch/x86/kernel/apic/apic.c:1118
asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:691
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x55/0x80 kernel/locking/spinlock.c:194
Code: 40 d2 ed 86 e8 dc 0b c4 fc 4c 89 f7 48 83 3d d1 8c fd 01 00 74 30 e8 1e 0d 00 00 90 f7 c3 00 02 00 00 74 01 fb bf 01 00 00 00 a6 50 5b fc 65 8b 05 37 28 12 7b 85 c0 74 05 5b 41 5e 5d c3 e8
RSP: 0018:ffffc9000386f5a0 EFLAGS: 00000206
RAX: 0000000000000001 RBX: 0000000000000a06 RCX: dffffc0000000000
RDX: ffffc90003987698 RSI: 0000000000000a06 RDI: 0000000000000001
RBP: ffffc9000386f5b0 R08: dffffc0000000000 R09: ffffed1029090799
R10: ffffed1029090799 R11: 1ffff11029090798 R12: ffff888114a51d00
R13: 0000000000000010 R14: 0000000000000001 R15: 0000000000000000
spin_unlock_irqrestore include/linux/spinlock.h:406 [inline]
__wake_up_common_lock kernel/sched/wait.c:141 [inline]
__wake_up_sync_key+0x166/0x280 kernel/sched/wait.c:212
__unix_dgram_recvmsg+0x496/0xd70 net/unix/af_unix.c:2476
unix_dgram_recvmsg+0xc7/0xe0 net/unix/af_unix.c:2546
____sys_recvmsg+0x2a0/0x590 net/socket.c:-1
___sys_recvmsg+0x1b2/0x510 net/socket.c:2770
do_recvmmsg+0x359/0x7a0 net/socket.c:2864
__sys_recvmmsg net/socket.c:2943 [inline]
__do_sys_recvmmsg net/socket.c:2966 [inline]
__se_sys_recvmmsg net/socket.c:2959 [inline]
__x64_sys_recvmmsg+0x18d/0x240 net/socket.c:2959
x64_sys_call+0x3e7/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:300
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
RIP: 0033:0x7f591198e929
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:00007f59127ef038 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 00007f5911bb6080 RCX: 00007f591198e929
RDX: 03fffffffffffeda RSI: 00002000000000c0 RDI: 0000000000000003
RBP: 00007f5911a10b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f5911bb6080 R15: 00007ffcd8476628
Allocated by task 287:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_alloc_info+0x25/0x30 mm/kasan/generic.c:505
__kasan_slab_alloc+0x72/0x80 mm/kasan/common.c:333
kasan_slab_alloc include/linux/kasan.h:202 [inline]
slab_post_alloc_hook+0x4f/0x2d0 mm/slab.h:768
slab_alloc_node mm/slub.c:3421 [inline]
slab_alloc mm/slub.c:3431 [inline]
__kmem_cache_alloc_lru mm/slub.c:3438 [inline]
kmem_cache_alloc+0x16e/0x330 mm/slub.c:3447
kmem_cache_zalloc include/linux/slab.h:689 [inline]
net_alloc net/core/net_namespace.c:413 [inline]
copy_net_ns+0x145/0x5c0 net/core/net_namespace.c:468
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:3388
__do_sys_unshare kernel/fork.c:3459 [inline]
__se_sys_unshare kernel/fork.c:3457 [inline]
__x64_sys_unshare+0x38/0x40 kernel/fork.c:3457
x64_sys_call+0x767/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
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 5371:
kasan_save_stack mm/kasan/common.c:45 [inline]
kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
kasan_save_free_info+0x31/0x50 mm/kasan/generic.c:516
____kasan_slab_free+0x132/0x180 mm/kasan/common.c:241
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
kasan_slab_free include/linux/kasan.h:178 [inline]
slab_free_hook mm/slub.c:1745 [inline]
slab_free_freelist_hook+0xc2/0x190 mm/slub.c:1771
slab_free mm/slub.c:3686 [inline]
kmem_cache_free+0x12d/0x300 mm/slub.c:3711
net_free net/core/net_namespace.c:442 [inline]
cleanup_net+0xa58/0xb00 net/core/net_namespace.c:625
process_one_work+0x71f/0xc40 kernel/workqueue.c:2299
worker_thread+0xa29/0x11f0 kernel/workqueue.c:2446
kthread+0x281/0x320 kernel/kthread.c:386
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
Last potentially related work creation:
kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
__kasan_record_aux_stack+0xb6/0xc0 mm/kasan/generic.c:486
kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
insert_work+0x51/0x300 kernel/workqueue.c:1368
__queue_work+0x9b1/0xd30 kernel/workqueue.c:1527
delayed_work_timer_fn+0x61/0x80 kernel/workqueue.c:1653
call_timer_fn+0x46/0x2a0 kernel/time/timer.c:1510
expire_timers kernel/time/timer.c:1550 [inline]
__run_timers+0x667/0x9a0 kernel/time/timer.c:1826
run_timer_softirq+0xb8/0xf0 kernel/time/timer.c:1841
handle_softirqs+0x1d7/0x600 kernel/softirq.c:642
__do_softirq kernel/softirq.c:680 [inline]
invoke_softirq kernel/softirq.c:497 [inline]
__irq_exit_rcu+0x52/0xf0 kernel/softirq.c:729
irq_exit_rcu+0x9/0x10 kernel/softirq.c:741
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
sysvec_apic_timer_interrupt+0xa9/0xc0 arch/x86/kernel/apic/apic.c:1118
asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:691
Second to last potentially related work creation:
kasan_save_stack+0x3a/0x60 mm/kasan/common.c:45
__kasan_record_aux_stack+0xb6/0xc0 mm/kasan/generic.c:486
kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496
insert_work+0x51/0x300 kernel/workqueue.c:1368
__queue_work+0x9b1/0xd30 kernel/workqueue.c:1527
delayed_work_timer_fn+0x61/0x80 kernel/workqueue.c:1653
call_timer_fn+0x46/0x2a0 kernel/time/timer.c:1510
expire_timers kernel/time/timer.c:1550 [inline]
__run_timers+0x667/0x9a0 kernel/time/timer.c:1826
run_timer_softirq+0xb8/0xf0 kernel/time/timer.c:1841
handle_softirqs+0x1d7/0x600 kernel/softirq.c:642
__do_softirq kernel/softirq.c:680 [inline]
invoke_softirq kernel/softirq.c:497 [inline]
__irq_exit_rcu+0x52/0xf0 kernel/softirq.c:729
irq_exit_rcu+0x9/0x10 kernel/softirq.c:741
instr_sysvec_call_function_single arch/x86/kernel/smp.c:262 [inline]
sysvec_call_function_single+0xa6/0xc0 arch/x86/kernel/smp.c:262
asm_sysvec_call_function_single+0x1b/0x20 arch/x86/include/asm/idtentry.h:699
The buggy address belongs to the object at ffff888110911180
which belongs to the cache net_namespace of size 4224
The buggy address is located 832 bytes inside of
4224-byte region [ffff888110911180, ffff888110912200)
The buggy address belongs to the physical page:
page:ffffea0004424400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x110910
head:ffffea0004424400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 0000000000000000 dead000000000122 ffff8881002ad500
raw: 0000000000000000 0000000080070007 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 283, tgid 283 (syz-executor), ts 22522996289, free_ts 22341966874
set_page_owner include/linux/page_owner.h:33 [inline]
post_alloc_hook+0x1f5/0x210 mm/page_alloc.c:2637
prep_new_page+0x1c/0x110 mm/page_alloc.c:2644
get_page_from_freelist+0x2c7b/0x2cf0 mm/page_alloc.c:4539
__alloc_pages+0x19e/0x3a0 mm/page_alloc.c:5850
alloc_slab_page+0x6e/0xf0 include/linux/gfp.h:-1
allocate_slab mm/slub.c:1962 [inline]
new_slab+0x98/0x3d0 mm/slub.c:2015
___slab_alloc+0x6f6/0xb50 mm/slub.c:3203
__slab_alloc+0x5e/0xa0 mm/slub.c:3302
slab_alloc_node mm/slub.c:3387 [inline]
slab_alloc mm/slub.c:3431 [inline]
__kmem_cache_alloc_lru mm/slub.c:3438 [inline]
kmem_cache_alloc+0x1b0/0x330 mm/slub.c:3447
kmem_cache_zalloc include/linux/slab.h:689 [inline]
net_alloc net/core/net_namespace.c:413 [inline]
copy_net_ns+0x145/0x5c0 net/core/net_namespace.c:468
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:3388
__do_sys_unshare kernel/fork.c:3459 [inline]
__se_sys_unshare kernel/fork.c:3457 [inline]
__x64_sys_unshare+0x38/0x40 kernel/fork.c:3457
x64_sys_call+0x767/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
page last free stack trace:
reset_page_owner include/linux/page_owner.h:26 [inline]
free_pages_prepare mm/page_alloc.c:1545 [inline]
free_pcp_prepare mm/page_alloc.c:1619 [inline]
free_unref_page_prepare+0x742/0x750 mm/page_alloc.c:3581
free_unref_page+0x8f/0x530 mm/page_alloc.c:3677
free_the_page mm/page_alloc.c:830 [inline]
free_compound_page+0x99/0xd0 mm/page_alloc.c:853
destroy_large_folio+0x68/0xa0 mm/page_alloc.c:890
__folio_put_large mm/swap.c:110 [inline]
__folio_put+0xd1/0xe0 mm/swap.c:118
folio_put include/linux/mm.h:1431 [inline]
put_page include/linux/mm.h:1483 [inline]
__skb_frag_unref include/linux/skbuff.h:3455 [inline]
skb_release_data+0x47f/0x890 net/core/skbuff.c:788
skb_release_all net/core/skbuff.c:859 [inline]
napi_consume_skb+0x13d/0x2c0 net/core/skbuff.c:1116
skb_defer_free_flush net/core/dev.c:6745 [inline]
net_rx_action+0x393/0xaa0 net/core/dev.c:6766
handle_softirqs+0x1d7/0x600 kernel/softirq.c:642
__do_softirq kernel/softirq.c:680 [inline]
invoke_softirq kernel/softirq.c:497 [inline]
__irq_exit_rcu+0x52/0xf0 kernel/softirq.c:729
irq_exit_rcu+0x9/0x10 kernel/softirq.c:741
common_interrupt+0xbe/0xe0 arch/x86/kernel/irq.c:242
asm_common_interrupt+0x27/0x40 arch/x86/include/asm/idtentry.h:682
Memory state around the buggy address:
ffff888110911380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888110911400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888110911480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888110911500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888110911580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
------------[ cut here ]------------
refcount_t: decrement hit 0; leaking memory.
WARNING: CPU: 0 PID: 11538 at lib/refcount.c:31 refcount_warn_saturate+0xe8/0x1a0 lib/refcount.c:31
Modules linked in:
CPU: 0 PID: 11538 Comm: syz.0.3846 Tainted: G B W 6.1.141-syzkaller-00036-g7011769d221c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
RIP: 0010:refcount_warn_saturate+0xe8/0x1a0 lib/refcount.c:31
Code: 05 01 0f 85 99 00 00 00 e8 95 b5 0c ff 5b 41 5e 5d c3 e8 8b b5 0c ff c6 05 ed ab 0b 05 01 48 c7 c7 e0 a1 a9 85 e8 38 fb dd fe <0f> 0b eb df e8 6f b5 0c ff c6 05 cf ab 0b 05 01 48 c7 c7 20 a1 a9
RSP: 0018:ffffc90000007cb0 EFLAGS: 00010246
RAX: ba70c8de37c08100 RBX: 0000000000000004 RCX: ffff88811a489440
RDX: 0000000000000100 RSI: 0000000000000000 RDI: 0000000000000002
RBP: ffffc90000007cc0 R08: dffffc0000000000 R09: fffff52000000f11
R10: fffff52000000f11 R11: 1ffff92000000f10 R12: ffff88810ec97650
R13: dffffc0000000000 R14: 0000000000000004 R15: 0000000000000001
FS: 00007f59127ef6c0(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000020000074b030 CR3: 000000017761b000 CR4: 00000000003526b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
__refcount_dec include/linux/refcount.h:344 [inline]
refcount_dec include/linux/refcount.h:359 [inline]
inet_twsk_kill+0x533/0x670 net/ipv4/inet_timewait_sock.c:72
tw_timer_handler+0x1c/0x20 net/ipv4/inet_timewait_sock.c:175
call_timer_fn+0x46/0x2a0 kernel/time/timer.c:1510
expire_timers kernel/time/timer.c:1555 [inline]
__run_timers+0x639/0x9a0 kernel/time/timer.c:1826
run_timer_softirq+0x6a/0xf0 kernel/time/timer.c:1839
handle_softirqs+0x1d7/0x600 kernel/softirq.c:642
__do_softirq kernel/softirq.c:680 [inline]
invoke_softirq kernel/softirq.c:497 [inline]
__irq_exit_rcu+0x52/0xf0 kernel/softirq.c:729
irq_exit_rcu+0x9/0x10 kernel/softirq.c:741
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
sysvec_apic_timer_interrupt+0xa9/0xc0 arch/x86/kernel/apic/apic.c:1118
asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:691
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x55/0x80 kernel/locking/spinlock.c:194
Code: 40 d2 ed 86 e8 dc 0b c4 fc 4c 89 f7 48 83 3d d1 8c fd 01 00 74 30 e8 1e 0d 00 00 90 f7 c3 00 02 00 00 74 01 fb bf 01 00 00 00 a6 50 5b fc 65 8b 05 37 28 12 7b 85 c0 74 05 5b 41 5e 5d c3 e8
RSP: 0018:ffffc9000386f5a0 EFLAGS: 00000206
RAX: 0000000000000001 RBX: 0000000000000a06 RCX: dffffc0000000000
RDX: ffffc90003987698 RSI: 0000000000000a06 RDI: 0000000000000001
RBP: ffffc9000386f5b0 R08: dffffc0000000000 R09: ffffed1029090799
R10: ffffed1029090799 R11: 1ffff11029090798 R12: ffff888114a51d00
R13: 0000000000000010 R14: 0000000000000001 R15: 0000000000000000
spin_unlock_irqrestore include/linux/spinlock.h:406 [inline]
__wake_up_common_lock kernel/sched/wait.c:141 [inline]
__wake_up_sync_key+0x166/0x280 kernel/sched/wait.c:212
__unix_dgram_recvmsg+0x496/0xd70 net/unix/af_unix.c:2476
unix_dgram_recvmsg+0xc7/0xe0 net/unix/af_unix.c:2546
____sys_recvmsg+0x2a0/0x590 net/socket.c:-1
___sys_recvmsg+0x1b2/0x510 net/socket.c:2770
do_recvmmsg+0x359/0x7a0 net/socket.c:2864
__sys_recvmmsg net/socket.c:2943 [inline]
__do_sys_recvmmsg net/socket.c:2966 [inline]
__se_sys_recvmmsg net/socket.c:2959 [inline]
__x64_sys_recvmmsg+0x18d/0x240 net/socket.c:2959
x64_sys_call+0x3e7/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:300
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
RIP: 0033:0x7f591198e929
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:00007f59127ef038 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 00007f5911bb6080 RCX: 00007f591198e929
RDX: 03fffffffffffeda RSI: 00002000000000c0 RDI: 0000000000000003
RBP: 00007f5911a10b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f5911bb6080 R15: 00007ffcd8476628
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess), 4 bytes skipped:
0: e8 dc 0b c4 fc call 0xfcc40be1
5: 4c 89 f7 mov %r14,%rdi
8: 48 83 3d d1 8c fd 01 cmpq $0x0,0x1fd8cd1(%rip) # 0x1fd8ce1
f: 00
10: 74 30 je 0x42
12: e8 1e 0d 00 00 call 0xd35
17: 90 nop
18: f7 c3 00 02 00 00 test $0x200,%ebx
1e: 74 01 je 0x21
20: fb sti
21: bf 01 00 00 00 mov $0x1,%edi
* 26: e8 a6 50 5b fc call 0xfc5b50d1 <-- trapping instruction
2b: 65 8b 05 37 28 12 7b mov %gs:0x7b122837(%rip),%eax # 0x7b122869
32: 85 c0 test %eax,%eax
34: 74 05 je 0x3b
36: 5b pop %rbx
37: 41 5e pop %r14
39: 5d pop %rbp
3a: c3 ret
3b: e8 .byte 0xe8