==================================================================
BUG: KASAN: slab-use-after-free in selinux_sock security/selinux/include/objsec.h:207 [inline]
BUG: KASAN: slab-use-after-free in selinux_ip_output+0x1e0/0x1f0 security/selinux/hooks.c:5761
Read of size 8 at addr ffff88804daeee38 by task syz.7.4602/23512
CPU: 0 UID: 0 PID: 23512 Comm: syz.7.4602 Not tainted 6.12.0-syzkaller-05480-gfcc79e1714e8 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
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:377 [inline]
print_report+0xc3/0x620 mm/kasan/report.c:488
kasan_report+0xd9/0x110 mm/kasan/report.c:601
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+0x386/0x6d0 include/linux/netfilter.h:269
__ip_local_out+0x339/0x640 net/ipv4/ip_output.c:119
ip_local_out net/ipv4/ip_output.c:128 [inline]
ip_send_skb net/ipv4/ip_output.c:1505 [inline]
ip_push_pending_frames+0xa0/0x5b0 net/ipv4/ip_output.c:1525
ip_send_unicast_reply+0xd0e/0x1650 net/ipv4/ip_output.c:1672
tcp_v4_send_reset+0x129d/0x2f10 net/ipv4/tcp_ipv4.c:910
tcp_v4_rcv+0x371d/0x4390 net/ipv4/tcp_ipv4.c:2431
ip_protocol_deliver_rcu+0xba/0x4c0 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x316/0x570 net/ipv4/ip_input.c:233
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_local_deliver+0x18e/0x1f0 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:460 [inline]
ip_rcv_finish net/ipv4/ip_input.c:447 [inline]
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_rcv+0x2c3/0x5d0 net/ipv4/ip_input.c:567
__netif_receive_skb_one_core+0x199/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:455 [inline]
do_softirq+0xb2/0xf0 kernel/softirq.c:442
__local_bh_enable_ip+0x100/0x120 kernel/softirq.c:382
local_bh_enable include/linux/bottom_half.h:33 [inline]
rcu_read_unlock_bh include/linux/rcupdate.h:919 [inline]
__dev_queue_xmit+0x8af/0x43e0 net/core/dev.c:4461
dev_queue_xmit include/linux/netdevice.h:3168 [inline]
neigh_hh_output include/net/neighbour.h:523 [inline]
neigh_output include/net/neighbour.h:537 [inline]
ip_finish_output2+0xc6c/0x2150 net/ipv4/ip_output.c:236
__ip_finish_output net/ipv4/ip_output.c:314 [inline]
__ip_finish_output+0x49e/0x950 net/ipv4/ip_output.c:296
ip_finish_output+0x35/0x380 net/ipv4/ip_output.c:324
NF_HOOK_COND include/linux/netfilter.h:303 [inline]
ip_output+0x13b/0x2a0 net/ipv4/ip_output.c:434
dst_output include/net/dst.h:450 [inline]
ip_local_out+0x33e/0x4a0 net/ipv4/ip_output.c:130
__ip_queue_xmit+0x777/0x1970 net/ipv4/ip_output.c:536
__tcp_transmit_skb+0x2b39/0x3df0 net/ipv4/tcp_output.c:1466
tcp_transmit_skb net/ipv4/tcp_output.c:1484 [inline]
tcp_write_xmit+0x12b1/0x8560 net/ipv4/tcp_output.c:2827
__tcp_push_pending_frames+0xaf/0x390 net/ipv4/tcp_output.c:3010
tcp_push+0x221/0x6f0 net/ipv4/tcp.c:751
mptcp_push_release.isra.0+0xa8/0xe0 net/mptcp/protocol.c:1503
__mptcp_push_pending+0x400/0x560 net/mptcp/protocol.c:1643
mptcp_sendmsg+0x1960/0x1f20 net/mptcp/protocol.c:1928
inet_sendmsg+0x119/0x140 net/ipv4/af_inet.c:851
sock_sendmsg_nosec net/socket.c:711 [inline]
__sock_sendmsg net/socket.c:726 [inline]
____sys_sendmsg+0x98c/0xc90 net/socket.c:2583
___sys_sendmsg+0x135/0x1e0 net/socket.c:2637
__sys_sendmsg+0x16e/0x220 net/socket.c:2669
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:0x7fa69617e819
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:00007fa696fba038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007fa696335fa0 RCX: 00007fa69617e819
RDX: 0000000004008094 RSI: 0000000020000980 RDI: 0000000000000008
RBP: 00007fa6961f175e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fa696335fa0 R15: 00007ffddec01ce8
Allocated by task 17034:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
unpoison_slab_object mm/kasan/common.c:319 [inline]
__kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:345
kasan_slab_alloc include/linux/kasan.h:247 [inline]
slab_post_alloc_hook mm/slub.c:4085 [inline]
slab_alloc_node mm/slub.c:4134 [inline]
kmem_cache_alloc_noprof+0x121/0x2f0 mm/slub.c:4141
inet_twsk_alloc+0x120/0x970 net/ipv4/inet_timewait_sock.c:188
tcp_time_wait+0x5f/0xe10 net/ipv4/tcp_minisocks.c:309
tcp_rcv_state_process+0x4935/0x4c40 net/ipv4/tcp_input.c:6917
tcp_v4_do_rcv+0x1ad/0xa90 net/ipv4/tcp_ipv4.c:1939
tcp_v4_rcv+0x33a8/0x4390 net/ipv4/tcp_ipv4.c:2351
ip_protocol_deliver_rcu+0xba/0x4c0 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x316/0x570 net/ipv4/ip_input.c:233
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_local_deliver+0x18e/0x1f0 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:460 [inline]
ip_rcv_finish net/ipv4/ip_input.c:447 [inline]
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_rcv+0x2c3/0x5d0 net/ipv4/ip_input.c:567
__netif_receive_skb_one_core+0x199/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+0x57/0xc0 arch/x86/kernel/apic/apic.c:1049
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
Freed by task 16:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
poison_slab_object mm/kasan/common.c:247 [inline]
__kasan_slab_free+0x51/0x70 mm/kasan/common.c:264
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:2342 [inline]
slab_free_after_rcu_debug+0x116/0x330 mm/slub.c:4629
rcu_do_batch kernel/rcu/tree.c:2567 [inline]
rcu_core+0x79d/0x14d0 kernel/rcu/tree.c:2823
handle_softirqs+0x213/0x8f0 kernel/softirq.c:554
run_ksoftirqd kernel/softirq.c:943 [inline]
run_ksoftirqd+0x3a/0x60 kernel/softirq.c:935
smpboot_thread_fn+0x661/0xa30 kernel/smpboot.c:164
kthread+0x2c1/0x3a0 kernel/kthread.c:389
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
Last potentially related work creation:
kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
__kasan_record_aux_stack+0xba/0xd0 mm/kasan/generic.c:541
slab_free_hook mm/slub.c:2303 [inline]
slab_free mm/slub.c:4579 [inline]
kmem_cache_free+0x305/0x4b0 mm/slub.c:4681
inet_twsk_free+0x12b/0x190 net/ipv4/inet_timewait_sock.c:78
inet_twsk_put+0x6a/0x90 net/ipv4/inet_timewait_sock.c:85
tcp_timewait_state_process+0x57d/0x1040 net/ipv4/tcp_minisocks.c:199
tcp_v4_rcv+0x29e6/0x4390 net/ipv4/tcp_ipv4.c:2407
ip_protocol_deliver_rcu+0xba/0x4c0 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x316/0x570 net/ipv4/ip_input.c:233
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_local_deliver+0x18e/0x1f0 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:460 [inline]
ip_rcv_finish net/ipv4/ip_input.c:447 [inline]
NF_HOOK include/linux/netfilter.h:314 [inline]
NF_HOOK include/linux/netfilter.h:308 [inline]
ip_rcv+0x2c3/0x5d0 net/ipv4/ip_input.c:567
__netif_receive_skb_one_core+0x199/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
The buggy address belongs to the object at ffff88804daeedc0
which belongs to the cache tw_sock_TCPv6 of size 288
The buggy address is located 120 bytes inside of
freed 288-byte region [ffff88804daeedc0, ffff88804daeeee0)
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88804daeec60 pfn:0x4daee
head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
memcg:ffff88804d547d01
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88802ec99000 dead000000000122 0000000000000000
raw: ffff88804daeec60 000000008017000e 00000001f5000000 ffff88804d547d01
head: 00fff00000000040 ffff88802ec99000 dead000000000122 0000000000000000
head: ffff88804daeec60 000000008017000e 00000001f5000000 ffff88804d547d01
head: 00fff00000000001 ffffea000136bb81 ffffffffffffffff 0000000000000000
head: ffff888000000002 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 0, tgid 0 (swapper/0), ts 77951591525, free_ts 76405070522
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/0x25a0 mm/page_alloc.c:4751
alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265
alloc_slab_page mm/slub.c:2412 [inline]
allocate_slab mm/slub.c:2578 [inline]
new_slab+0x2c9/0x410 mm/slub.c:2631
___slab_alloc+0xdac/0x1880 mm/slub.c:3818
__slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3908
__slab_alloc_node mm/slub.c:3961 [inline]
slab_alloc_node mm/slub.c:4122 [inline]
kmem_cache_alloc_noprof+0x2a7/0x2f0 mm/slub.c:4141
inet_twsk_alloc+0x120/0x970 net/ipv4/inet_timewait_sock.c:188
tcp_time_wait+0x5f/0xe10 net/ipv4/tcp_minisocks.c:309
tcp_rcv_state_process+0x4935/0x4c40 net/ipv4/tcp_input.c:6917
tcp_v6_do_rcv+0x492/0x1730 net/ipv6/tcp_ipv6.c:1667
tcp_v6_rcv+0x30b3/0x3fd0 net/ipv6/tcp_ipv6.c:1914
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
page last free pid 6073 tgid 6071 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
kasan_depopulate_vmalloc_pte+0x63/0x80 mm/kasan/shadow.c:408
apply_to_pte_range mm/memory.c:2817 [inline]
apply_to_pmd_range mm/memory.c:2861 [inline]
apply_to_pud_range mm/memory.c:2897 [inline]
apply_to_p4d_range mm/memory.c:2933 [inline]
__apply_to_page_range+0x5fd/0xd30 mm/memory.c:2967
kasan_release_vmalloc+0xac/0xc0 mm/kasan/shadow.c:525
purge_vmap_node+0x3fb/0x930 mm/vmalloc.c:2204
__purge_vmap_area_lazy+0x9c5/0xc00 mm/vmalloc.c:2288
_vm_unmap_aliases+0x448/0x670 mm/vmalloc.c:2883
change_page_attr_set_clr+0x24c/0x490 arch/x86/mm/pat/set_memory.c:1881
cpa_set_pages_array arch/x86/mm/pat/set_memory.c:1936 [inline]
_set_pages_array+0x175/0x260 arch/x86/mm/pat/set_memory.c:2317
drm_gem_shmem_get_pages+0x1f8/0x300 drivers/gpu/drm/drm_gem_shmem_helper.c:192
drm_gem_pin_locked drivers/gpu/drm/drm_gem.c:1164 [inline]
drm_gem_pin+0x9c/0x110 drivers/gpu/drm/drm_gem.c:1180
drm_gem_map_attach+0x8c/0x120 drivers/gpu/drm/drm_prime.c:617
dma_buf_dynamic_attach+0x202/0xa40 drivers/dma-buf/dma-buf.c:928
drm_gem_prime_import_dev drivers/gpu/drm/drm_prime.c:958 [inline]
drm_gem_prime_import_dev+0xb4/0x440 drivers/gpu/drm/drm_prime.c:934
drm_gem_prime_import drivers/gpu/drm/drm_prime.c:1007 [inline]
drm_gem_prime_fd_to_handle+0x443/0x590 drivers/gpu/drm/drm_prime.c:319
drm_prime_fd_to_handle_ioctl+0xd6/0x110 drivers/gpu/drm/drm_prime.c:375
Memory state around the buggy address:
ffff88804daeed00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88804daeed80: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff88804daeee00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88804daeee80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
ffff88804daeef00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================