================================================================== BUG: KASAN: use-after-free in inet_twsk_kill+0x358/0x3c0 net/ipv4/inet_timewait_sock.c:46 Read of size 8 at addr ffff888018191900 by task syz-executor.0/18624 CPU: 0 PID: 18624 Comm: syz-executor.0 Not tainted 5.17.0-rc1-next-20220127 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x8b/0xb3 lib/dump_stack.c:106 print_address_description.constprop.0+0x1f/0x190 mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x7f/0x11b mm/kasan/report.c:459 inet_twsk_kill+0x358/0x3c0 net/ipv4/inet_timewait_sock.c:46 call_timer_fn+0x182/0x600 kernel/time/timer.c:1421 expire_timers kernel/time/timer.c:1466 [inline] __run_timers.part.0+0x666/0xa00 kernel/time/timer.c:1734 __run_timers kernel/time/timer.c:1715 [inline] run_timer_softirq+0xae/0x1a0 kernel/time/timer.c:1747 __do_softirq+0x270/0x8c7 kernel/softirq.c:558 invoke_softirq kernel/softirq.c:432 [inline] __irq_exit_rcu+0x113/0x170 kernel/softirq.c:637 irq_exit_rcu+0x5/0x20 kernel/softirq.c:649 sysvec_apic_timer_interrupt+0x8e/0xc0 arch/x86/kernel/apic/apic.c:1097 asm_sysvec_apic_timer_interrupt+0x12/0x20 arch/x86/include/asm/idtentry.h:638 RIP: 0010:folio_test_anon include/linux/page-flags.h:651 [inline] RIP: 0010:PageAnon include/linux/page-flags.h:656 [inline] RIP: 0010:zap_pte_range mm/memory.c:1370 [inline] RIP: 0010:zap_pmd_range mm/memory.c:1490 [inline] RIP: 0010:zap_pud_range mm/memory.c:1519 [inline] RIP: 0010:zap_p4d_range mm/memory.c:1540 [inline] RIP: 0010:unmap_page_range+0xb23/0x2380 mm/memory.c:1561 Code: dd ff 0f 1f 44 00 00 e8 0b 92 dd ff 48 89 eb e8 03 92 dd ff 48 8d 7b 18 48 89 f8 48 c1 e8 03 42 80 3c 38 00 0f 85 48 14 00 00 <48> 8b 5b 18 31 ff 83 e3 01 89 de e8 bd 95 dd ff 84 db 0f 85 9a 00 RSP: 0018:ffff88803d67f9e0 EFLAGS: 00000246 RAX: 1ffffd40001830cb RBX: ffffea0000c18640 RCX: 0000000000000000 RDX: ffff88803981b580 RSI: ffffffff8165ae2d RDI: ffffea0000c18658 RBP: ffffea0000c18640 R08: 0000000000000000 R09: 0000000000000001 R10: ffffffff8165ae0d R11: 0000000000000000 R12: ffffea0000c18648 R13: ffff88803d67fcf0 R14: ffff88803d17f880 R15: dffffc0000000000 unmap_single_vma+0x198/0x310 mm/memory.c:1606 unmap_vmas+0x16b/0x2f0 mm/memory.c:1638 exit_mmap+0x1cf/0x630 mm/mmap.c:3178 __mmput kernel/fork.c:1114 [inline] mmput+0xc8/0x380 kernel/fork.c:1135 exit_mm kernel/exit.c:507 [inline] do_exit+0xa34/0x2830 kernel/exit.c:793 do_group_exit+0xd2/0x2f0 kernel/exit.c:935 __do_sys_exit_group kernel/exit.c:946 [inline] __se_sys_exit_group kernel/exit.c:944 [inline] __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f1c4a5ebb19 Code: Unable to access opcode bytes at RIP 0x7f1c4a5ebaef. RSP: 002b:00007ffed64c53d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 000000000000001e RCX: 00007f1c4a5ebb19 RDX: 00007f1c4a59e72b RSI: ffffffffffffffbc RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001 R13: 0000000000000001 R14: 0000000000000001 R15: 00007ffed64c54c0 Allocated by task 8372: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:469 kasan_slab_alloc include/linux/kasan.h:260 [inline] slab_post_alloc_hook mm/slab.h:732 [inline] slab_alloc_node mm/slub.c:3230 [inline] slab_alloc mm/slub.c:3238 [inline] kmem_cache_alloc+0x1aa/0x480 mm/slub.c:3243 kmem_cache_zalloc include/linux/slab.h:705 [inline] net_alloc net/core/net_namespace.c:407 [inline] copy_net_ns+0x125/0x760 net/core/net_namespace.c:462 create_new_namespaces+0x3f6/0xb30 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0xc1/0x1f0 kernel/nsproxy.c:226 ksys_unshare+0x445/0x8d0 kernel/fork.c:3048 __do_sys_unshare kernel/fork.c:3119 [inline] __se_sys_unshare kernel/fork.c:3117 [inline] __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3117 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0x90 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff8880181914c0 which belongs to the cache net_namespace of size 5056 The buggy address is located 1088 bytes inside of 5056-byte region [ffff8880181914c0, ffff888018192880) The buggy address belongs to the page: page:00000000e5264b99 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880181914c0 pfn:0x18190 head:00000000e5264b99 order:3 compound_mapcount:0 compound_pincount:0 memcg:ffff88800dd54f01 flags: 0x100000000010200(slab|head|node=0|zone=1) raw: 0100000000010200 0000000000000000 dead000000000001 ffff88800805d640 raw: ffff8880181914c0 0000000080060002 00000001ffffffff ffff88800dd54f01 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888018191800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888018191880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888018191900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888018191980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888018191a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== loop1: detected capacity change from 0 to 147456 loop3: detected capacity change from 0 to 147456 loop4: detected capacity change from 0 to 147456 loop4: detected capacity change from 0 to 147456 loop3: detected capacity change from 0 to 147456 loop1: detected capacity change from 0 to 147456 loop4: detected capacity change from 0 to 147456 loop3: detected capacity change from 0 to 147456 blktrace: Concurrent blktraces are not allowed on sg0 blktrace: Concurrent blktraces are not allowed on sg0 blktrace: Concurrent blktraces are not allowed on sg0 blktrace: Concurrent blktraces are not allowed on sg0 tmpfs: Bad value for 'size' tmpfs: Bad value for 'size' tmpfs: Bad value for 'size' tmpfs: Bad value for 'size' tmpfs: Bad value for 'size' loop6: detected capacity change from 0 to 5168 loop6: detected capacity change from 0 to 5168 loop6: detected capacity change from 0 to 5168 loop6: detected capacity change from 0 to 5168 loop4: detected capacity change from 0 to 8 nfs4: Unknown parameter 'lo' loop4: detected capacity change from 0 to 8 nfs4: Unknown parameter 'lo' loop4: detected capacity change from 0 to 8 nfs4: Unknown parameter 'lo' loop7: detected capacity change from 0 to 512 loop6: detected capacity change from 0 to 40 syz-executor.6: attempt to access beyond end of device loop6: rw=2049, want=128, limit=40 Buffer I/O error on dev loop6, logical block 31, lost async page write syz-executor.6: attempt to access beyond end of device loop6: rw=2049, want=128, limit=40 Buffer I/O error on dev loop6, logical block 31, lost async page write EXT4-fs (loop7): mounted filesystem without journal. Quota mode: none. EXT4-fs error (device loop7): ext4_readdir:258: inode #2: block 6: comm syz-executor.7: path /syzkaller-testdir128174023/syzkaller.NeeTWj/493/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 loop7: detected capacity change from 0 to 512 EXT4-fs (loop7): mounted filesystem without journal. Quota mode: none. loop6: detected capacity change from 0 to 40 loop4: detected capacity change from 0 to 512 EXT4-fs error (device loop7): ext4_readdir:258: inode #2: block 6: comm syz-executor.7: path /syzkaller-testdir128174023/syzkaller.NeeTWj/494/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 EXT4-fs (loop4): mounted filesystem without journal. Quota mode: none. loop3: detected capacity change from 0 to 40 syz-executor.6: attempt to access beyond end of device loop6: rw=2049, want=128, limit=40 Buffer I/O error on dev loop6, logical block 31, lost async page write EXT4-fs error (device loop4): ext4_readdir:258: inode #2: block 6: comm syz-executor.4: path /syzkaller-testdir163668626/syzkaller.xfSX2y/531/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 syz-executor.3: attempt to access beyond end of device loop3: rw=2049, want=128, limit=40 Buffer I/O error on dev loop3, logical block 31, lost async page write loop7: detected capacity change from 0 to 512 EXT4-fs (loop7): mounted filesystem without journal. Quota mode: none. EXT4-fs error (device loop7): ext4_readdir:258: inode #2: block 6: comm syz-executor.7: path /syzkaller-testdir128174023/syzkaller.NeeTWj/495/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 loop4: detected capacity change from 0 to 512 loop6: detected capacity change from 0 to 40 loop3: detected capacity change from 0 to 40 loop7: detected capacity change from 0 to 512 syz-executor.6: attempt to access beyond end of device loop6: rw=2049, want=128, limit=40 Buffer I/O error on dev loop6, logical block 31, lost async page write EXT4-fs (loop4): mounted filesystem without journal. Quota mode: none. EXT4-fs (loop7): mounted filesystem without journal. Quota mode: none. EXT4-fs error (device loop4): ext4_readdir:258: inode #2: block 6: comm syz-executor.4: path /syzkaller-testdir163668626/syzkaller.xfSX2y/532/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 syz-executor.3: attempt to access beyond end of device loop3: rw=2049, want=128, limit=40 Buffer I/O error on dev loop3, logical block 31, lost async page write EXT4-fs error (device loop7): ext4_readdir:258: inode #2: block 6: comm syz-executor.7: path /syzkaller-testdir128174023/syzkaller.NeeTWj/496/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 loop4: detected capacity change from 0 to 512 loop3: detected capacity change from 0 to 40 loop6: detected capacity change from 0 to 40 syz-executor.6: attempt to access beyond end of device loop6: rw=2049, want=128, limit=40 Buffer I/O error on dev loop6, logical block 31, lost async page write syz-executor.3: attempt to access beyond end of device loop3: rw=2049, want=128, limit=40 Buffer I/O error on dev loop3, logical block 31, lost async page write EXT4-fs (loop4): mounted filesystem without journal. Quota mode: none. EXT4-fs error (device loop4): ext4_readdir:258: inode #2: block 6: comm syz-executor.4: path /syzkaller-testdir163668626/syzkaller.xfSX2y/533/file0: bad entry in directory: rec_len is smaller than minimal - offset=0, inode=0, rec_len=0, size=4096 fake=0 loop4: detected capacity change from 0 to 40 loop1: detected capacity change from 0 to 40 syz-executor.4: attempt to access beyond end of device loop4: rw=2049, want=128, limit=40 Buffer I/O error on dev loop4, logical block 31, lost async page write syz-executor.1: attempt to access beyond end of device loop1: rw=2049, want=128, limit=40 Buffer I/O error on dev loop1, logical block 31, lost async page write loop1: detected capacity change from 0 to 40 loop4: detected capacity change from 0 to 40 I/O error, dev loop4, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0 loop1: detected capacity change from 0 to 40 loop4: detected capacity change from 0 to 40 ---------------- Code disassembly (best guess), 2 bytes skipped: 0: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 5: e8 0b 92 dd ff callq 0xffdd9215 a: 48 89 eb mov %rbp,%rbx d: e8 03 92 dd ff callq 0xffdd9215 12: 48 8d 7b 18 lea 0x18(%rbx),%rdi 16: 48 89 f8 mov %rdi,%rax 19: 48 c1 e8 03 shr $0x3,%rax 1d: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) 22: 0f 85 48 14 00 00 jne 0x1470 * 28: 48 8b 5b 18 mov 0x18(%rbx),%rbx <-- trapping instruction 2c: 31 ff xor %edi,%edi 2e: 83 e3 01 and $0x1,%ebx 31: 89 de mov %ebx,%esi 33: e8 bd 95 dd ff callq 0xffdd95f5 38: 84 db test %bl,%bl 3a: 0f .byte 0xf 3b: 85 .byte 0x85 3c: 9a (bad)