================================================================== BUG: KASAN: slab-use-after-free in __xfrm_state_insert+0x24fc/0x2510 net/xfrm/xfrm_state.c:1743 Read of size 1 at addr ffff888065eddc70 by task syz.3.1667/12483 CPU: 0 UID: 0 PID: 12483 Comm: syz.3.1667 Not tainted syzkaller #0 PREEMPT(full) 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+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 __xfrm_state_insert+0x24fc/0x2510 net/xfrm/xfrm_state.c:1743 xfrm_state_insert+0x4c/0x60 net/xfrm/xfrm_state.c:1795 ipcomp6_tunnel_attach net/ipv6/ipcomp6.c:131 [inline] ipcomp6_init_state net/ipv6/ipcomp6.c:163 [inline] ipcomp6_init_state+0x608/0x8d0 net/ipv6/ipcomp6.c:141 __xfrm_init_state+0x6fe/0x1c10 net/xfrm/xfrm_state.c:3188 xfrm_init_state+0x18/0xa0 net/xfrm/xfrm_state.c:3231 pfkey_msg2xfrm_state net/key/af_key.c:1286 [inline] pfkey_add+0x24f4/0x2ec0 net/key/af_key.c:1504 pfkey_process+0x6d9/0x840 net/key/af_key.c:2848 pfkey_sendmsg+0x435/0x850 net/key/af_key.c:3699 sock_sendmsg_nosec net/socket.c:714 [inline] __sock_sendmsg net/socket.c:729 [inline] ____sys_sendmsg+0xa95/0xc70 net/socket.c:2614 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2668 __sys_sendmsg+0x16d/0x220 net/socket.c:2700 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x3a0 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf7fc5579 Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 RSP: 002b:00000000f54e655c EFLAGS: 00000296 ORIG_RAX: 0000000000000172 RAX: ffffffffffffffda RBX: 0000000000000007 RCX: 00000000800001c0 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 11511: 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:330 [inline] __kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:356 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4180 [inline] slab_alloc_node mm/slub.c:4229 [inline] kmem_cache_alloc_noprof+0x1cb/0x3b0 mm/slub.c:4236 xfrm_state_alloc+0x23/0x5c0 net/xfrm/xfrm_state.c:733 __find_acq_core+0xb59/0x2900 net/xfrm/xfrm_state.c:1833 xfrm_find_acq+0x7b/0xa0 net/xfrm/xfrm_state.c:2353 xfrm_alloc_userspi+0x58e/0xbb0 net/xfrm/xfrm_user.c:1863 xfrm_user_rcv_msg+0x4fe/0xb60 net/xfrm/xfrm_user.c:3501 netlink_rcv_skb+0x155/0x420 net/netlink/af_netlink.c:2552 xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3523 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1346 netlink_sendmsg+0x8d1/0xdd0 net/netlink/af_netlink.c:1896 sock_sendmsg_nosec net/socket.c:714 [inline] __sock_sendmsg net/socket.c:729 [inline] ____sys_sendmsg+0xa95/0xc70 net/socket.c:2614 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2668 __sys_sendmsg+0x16d/0x220 net/socket.c:2700 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x3a0 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 6025: 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:576 poison_slab_object mm/kasan/common.c:243 [inline] __kasan_slab_free+0x60/0x70 mm/kasan/common.c:275 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2417 [inline] slab_free mm/slub.c:4680 [inline] kmem_cache_free+0x2d1/0x4d0 mm/slub.c:4782 xfrm_state_free net/xfrm/xfrm_state.c:591 [inline] xfrm_state_gc_destroy net/xfrm/xfrm_state.c:618 [inline] xfrm_state_gc_task+0x50a/0x770 net/xfrm/xfrm_state.c:634 process_one_work+0x9cf/0x1b70 kernel/workqueue.c:3236 process_scheduled_works kernel/workqueue.c:3319 [inline] worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400 kthread+0x3c5/0x780 kernel/kthread.c:463 ret_from_fork+0x5d4/0x6f0 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 The buggy address belongs to the object at ffff888065edd940 which belongs to the cache xfrm_state of size 928 The buggy address is located 816 bytes inside of freed 928-byte region [ffff888065edd940, ffff888065eddce0) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff888065edd940 pfn:0x65ed8 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x4fff00000000040(head|node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000040 ffff88801da93180 dead000000000122 0000000000000000 raw: ffff888065edd940 00000000801e0008 00000000f5000000 0000000000000000 head: 04fff00000000040 ffff88801da93180 dead000000000122 0000000000000000 head: ffff888065edd940 00000000801e0008 00000000f5000000 0000000000000000 head: 04fff00000000003 ffffea000197b601 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 6807, tgid 6802 (syz.1.179), ts 76811031445, free_ts 56193931281 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1851 prep_new_page mm/page_alloc.c:1859 [inline] get_page_from_freelist+0x132b/0x38e0 mm/page_alloc.c:3858 __alloc_frozen_pages_noprof+0x261/0x23f0 mm/page_alloc.c:5148 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416 alloc_slab_page mm/slub.c:2487 [inline] allocate_slab mm/slub.c:2655 [inline] new_slab+0x247/0x330 mm/slub.c:2709 ___slab_alloc+0xcf2/0x1740 mm/slub.c:3891 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3981 __slab_alloc_node mm/slub.c:4056 [inline] slab_alloc_node mm/slub.c:4217 [inline] kmem_cache_alloc_noprof+0xef/0x3b0 mm/slub.c:4236 xfrm_state_alloc+0x23/0x5c0 net/xfrm/xfrm_state.c:733 xfrm_state_find+0x31e6/0x84c0 net/xfrm/xfrm_state.c:1513 xfrm_tmpl_resolve_one net/xfrm/xfrm_policy.c:2522 [inline] xfrm_tmpl_resolve net/xfrm/xfrm_policy.c:2573 [inline] xfrm_resolve_and_create_bundle+0x4cd/0x3740 net/xfrm/xfrm_policy.c:2871 xfrm_lookup_with_ifid+0x2a0/0x1e40 net/xfrm/xfrm_policy.c:3205 xfrm_lookup net/xfrm/xfrm_policy.c:3336 [inline] xfrm_lookup_route+0x3b/0x200 net/xfrm/xfrm_policy.c:3347 ip_route_output_flow+0x11e/0x150 net/ipv4/route.c:2930 udp_sendmsg+0x1af9/0x2870 net/ipv4/udp.c:1450 inet_sendmsg+0x105/0x140 net/ipv4/af_inet.c:851 page last free pid 5966 tgid 5966 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1395 [inline] __free_frozen_pages+0x7d5/0x10f0 mm/page_alloc.c:2895 vfree+0x1fd/0xb50 mm/vmalloc.c:3434 kcov_put kernel/kcov.c:439 [inline] kcov_put kernel/kcov.c:435 [inline] kcov_close+0x34/0x60 kernel/kcov.c:535 __fput+0x402/0xb70 fs/file_table.c:468 task_work_run+0x14d/0x240 kernel/task_work.c:227 exit_task_work include/linux/task_work.h:40 [inline] do_exit+0x86f/0x2bf0 kernel/exit.c:961 do_group_exit+0xd3/0x2a0 kernel/exit.c:1102 __do_sys_exit_group kernel/exit.c:1113 [inline] __se_sys_exit_group kernel/exit.c:1111 [inline] __ia32_sys_exit_group+0x3e/0x50 kernel/exit.c:1111 ia32_sys_call+0xa9e/0x1ca0 arch/x86/include/generated/asm/syscalls_32.h:253 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline] __do_fast_syscall_32+0x7c/0x3a0 arch/x86/entry/syscall_32.c:306 do_fast_syscall_32+0x32/0x80 arch/x86/entry/syscall_32.c:331 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Memory state around the buggy address: ffff888065eddb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888065eddb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888065eddc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888065eddc80: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff888065eddd00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ================================================================== ---------------- Code disassembly (best guess), 2 bytes skipped: 0: 10 06 adc %al,(%rsi) 2: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 6: 10 07 adc %al,(%rdi) 8: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi c: 10 08 adc %cl,(%rax) e: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1e: 00 51 52 add %dl,0x52(%rcx) 21: 55 push %rbp 22: 89 e5 mov %esp,%ebp 24: 0f 34 sysenter 26: cd 80 int $0x80 * 28: 5d pop %rbp <-- trapping instruction 29: 5a pop %rdx 2a: 59 pop %rcx 2b: c3 ret 2c: 90 nop 2d: 90 nop 2e: 90 nop 2f: 90 nop 30: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 37: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi