================================================================== BUG: KASAN: slab-out-of-bounds in selinux_sock security/selinux/include/objsec.h:207 [inline] BUG: KASAN: slab-out-of-bounds in selinux_ip_output+0x1e0/0x1f0 security/selinux/hooks.c:5761 Read of size 8 at addr ffff888029a4a5f8 by task syz.1.982/9609 CPU: 0 UID: 0 PID: 9609 Comm: syz.1.982 Not tainted 6.13.0-rc1-syzkaller-00025-gfeffde684ac2 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xc3/0x620 mm/kasan/report.c:489 kasan_report+0xd9/0x110 mm/kasan/report.c:602 selinux_sock security/selinux/include/objsec.h:207 [inline] selinux_ip_output+0x1e0/0x1f0 security/selinux/hooks.c:5761 nf_hook_entry_hookfn include/linux/netfilter.h:154 [inline] nf_hook_slow+0xbb/0x200 net/netfilter/core.c:626 nf_hook+0x474/0x7d0 include/linux/netfilter.h:269 NF_HOOK include/linux/netfilter.h:312 [inline] ip6_xmit+0xd44/0x2130 net/ipv6/ip6_output.c:366 tcp_v6_send_response+0x11d9/0x25e0 net/ipv6/tcp_ipv6.c:999 tcp_v6_send_ack net/ipv6/tcp_ipv6.c:1152 [inline] tcp_v6_timewait_ack net/ipv6/tcp_ipv6.c:1199 [inline] tcp_v6_rcv+0x2c9c/0x3fd0 net/ipv6/tcp_ipv6.c:1993 ip6_protocol_deliver_rcu+0x180/0x1510 net/ipv6/ip6_input.c:436 ip6_input_finish+0x14f/0x2f0 net/ipv6/ip6_input.c:481 NF_HOOK include/linux/netfilter.h:314 [inline] NF_HOOK include/linux/netfilter.h:308 [inline] ip6_input+0xa1/0xd0 net/ipv6/ip6_input.c:490 dst_input include/net/dst.h:460 [inline] ip6_rcv_finish net/ipv6/ip6_input.c:79 [inline] NF_HOOK include/linux/netfilter.h:314 [inline] NF_HOOK include/linux/netfilter.h:308 [inline] ipv6_rcv+0x265/0x680 net/ipv6/ip6_input.c:309 __netif_receive_skb_one_core+0x12e/0x1e0 net/core/dev.c:5672 __netif_receive_skb+0x1d/0x160 net/core/dev.c:5785 process_backlog+0x443/0x15f0 net/core/dev.c:6117 __napi_poll.constprop.0+0xb7/0x550 net/core/dev.c:6877 napi_poll net/core/dev.c:6946 [inline] net_rx_action+0xa94/0x1010 net/core/dev.c:7068 handle_softirqs+0x213/0x8f0 kernel/softirq.c:554 __do_softirq kernel/softirq.c:588 [inline] invoke_softirq kernel/softirq.c:428 [inline] __irq_exit_rcu+0x109/0x170 kernel/softirq.c:655 irq_exit_rcu+0x9/0x30 kernel/softirq.c:671 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline] sysvec_apic_timer_interrupt+0xa4/0xc0 arch/x86/kernel/apic/apic.c:1049 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702 RIP: 0010:__folio_remove_rmap mm/rmap.c:1547 [inline] RIP: 0010:folio_remove_rmap_ptes+0x9a/0x3c0 mm/rmap.c:1620 Code: 44 89 e6 e8 68 6b af ff 45 84 e4 0f 85 c7 00 00 00 e8 7a 69 af ff 49 8d 7d 30 be 04 00 00 00 e8 5c 59 12 00 f0 41 83 45 30 ff <0f> 98 c3 31 ff 0f b6 db f7 db 89 de e8 95 6b af ff 85 db 74 49 e8 RSP: 0018:ffffc900065f7858 EFLAGS: 00000213 RAX: 0000000000000001 RBX: ffffea000123f900 RCX: ffffffff81ea9ca4 RDX: fffff94000247f27 RSI: 0000000000000004 RDI: ffffea000123f930 RBP: 0000000000000001 R08: 0000000000000001 R09: fffff94000247f26 R10: ffffea000123f933 R11: 0000000000000003 R12: 0000000000000000 R13: ffffea000123f900 R14: ffff8880271edd90 R15: ffffc900065f7cc8 zap_present_folio_ptes mm/memory.c:1526 [inline] zap_present_ptes mm/memory.c:1585 [inline] zap_pte_range mm/memory.c:1627 [inline] zap_pmd_range mm/memory.c:1753 [inline] zap_pud_range mm/memory.c:1782 [inline] zap_p4d_range mm/memory.c:1803 [inline] unmap_page_range+0x1965/0x3d60 mm/memory.c:1824 unmap_single_vma+0x194/0x2b0 mm/memory.c:1870 unmap_vmas+0x22f/0x490 mm/memory.c:1914 exit_mmap+0x1c6/0xb20 mm/mmap.c:1667 __mmput+0x12a/0x4c0 kernel/fork.c:1353 mmput+0x62/0x70 kernel/fork.c:1375 exit_mm kernel/exit.c:570 [inline] do_exit+0x9bf/0x2d70 kernel/exit.c:925 do_group_exit+0xd3/0x2a0 kernel/exit.c:1087 __do_sys_exit_group kernel/exit.c:1098 [inline] __se_sys_exit_group kernel/exit.c:1096 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1096 x64_sys_call+0x151f/0x1720 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f6efdf7ff19 Code: Unable to access opcode bytes at 0x7f6efdf7feef. RSP: 002b:00007ffe376ba4e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f6efdf7ff19 RDX: 0000000000000064 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 00007ffe376ba53c R08: 00007ffe376ba5cf R09: 00000000000170b9 R10: 0000000000000190 R11: 0000000000000246 R12: 0000000000000032 R13: 00000000000170b9 R14: 000000000001709a R15: 00007ffe376ba590 The buggy address belongs to the object at ffff888029a4a580 which belongs to the cache tw_sock_TCPv6 of size 288 The buggy address is located 120 bytes inside of allocated 288-byte region [ffff888029a4a580, ffff888029a4a6a0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x29a4a head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 memcg:ffff8880256e8e01 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801e68ac80 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080170017 00000001f5000000 ffff8880256e8e01 head: 00fff00000000040 ffff88801e68ac80 dead000000000122 0000000000000000 head: 0000000000000000 0000000080170017 00000001f5000000 ffff8880256e8e01 head: 00fff00000000001 ffffea0000a69281 ffffffffffffffff 0000000000000000 head: 0000000000000002 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 6551, tgid 6551 (kworker/0:4), ts 60569264162, free_ts 60459446884 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1556 prep_new_page mm/page_alloc.c:1564 [inline] get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3474 __alloc_pages_noprof+0x223/0x25b0 mm/page_alloc.c:4751 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2408 [inline] allocate_slab mm/slub.c:2574 [inline] new_slab+0x2c9/0x410 mm/slub.c:2627 ___slab_alloc+0xdac/0x1870 mm/slub.c:3815 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3905 __slab_alloc_node mm/slub.c:3980 [inline] slab_alloc_node mm/slub.c:4141 [inline] kmem_cache_alloc_noprof+0xfa/0x3d0 mm/slub.c:4160 inet_twsk_alloc+0x120/0x970 net/ipv4/inet_timewait_sock.c:188 tcp_time_wait+0x5f/0xe10 net/ipv4/tcp_minisocks.c:309 tcp_fin+0x418/0x500 net/ipv4/tcp_input.c:4604 tcp_data_queue+0x1d61/0x4d80 net/ipv4/tcp_input.c:5290 tcp_rcv_state_process+0xf6f/0x4c40 net/ipv4/tcp_input.c:6972 tcp_v4_do_rcv+0x1ad/0xa90 net/ipv4/tcp_ipv4.c:1939 tcp_v4_rcv+0x33a0/0x4380 net/ipv4/tcp_ipv4.c:2351 ip_protocol_deliver_rcu+0xba/0x4c0 net/ipv4/ip_input.c:205 page last free pid 5352 tgid 5352 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0x661/0x1080 mm/page_alloc.c:2657 __put_partials+0x14c/0x170 mm/slub.c:3142 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x195/0x1e0 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4104 [inline] slab_alloc_node mm/slub.c:4153 [inline] __do_kmalloc_node mm/slub.c:4282 [inline] __kmalloc_noprof+0x1cd/0x510 mm/slub.c:4295 kmalloc_noprof include/linux/slab.h:905 [inline] tomoyo_realpath_from_path+0xb9/0x720 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x276/0x460 security/tomoyo/file.c:822 security_inode_getattr+0x116/0x290 security/security.c:2372 vfs_getattr fs/stat.c:243 [inline] vfs_fstat+0x4b/0xd0 fs/stat.c:265 vfs_fstatat+0xbc/0xf0 fs/stat.c:364 __do_sys_newfstatat+0xa2/0x130 fs/stat.c:530 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff888029a4a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888029a4a500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888029a4a580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff888029a4a600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888029a4a680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== ---------------- Code disassembly (best guess): 0: 44 89 e6 mov %r12d,%esi 3: e8 68 6b af ff call 0xffaf6b70 8: 45 84 e4 test %r12b,%r12b b: 0f 85 c7 00 00 00 jne 0xd8 11: e8 7a 69 af ff call 0xffaf6990 16: 49 8d 7d 30 lea 0x30(%r13),%rdi 1a: be 04 00 00 00 mov $0x4,%esi 1f: e8 5c 59 12 00 call 0x125980 24: f0 41 83 45 30 ff lock addl $0xffffffff,0x30(%r13) * 2a: 0f 98 c3 sets %bl <-- trapping instruction 2d: 31 ff xor %edi,%edi 2f: 0f b6 db movzbl %bl,%ebx 32: f7 db neg %ebx 34: 89 de mov %ebx,%esi 36: e8 95 6b af ff call 0xffaf6bd0 3b: 85 db test %ebx,%ebx 3d: 74 49 je 0x88 3f: e8 .byte 0xe8