syzbot


KASAN: slab-use-after-free Read in __xfrm_state_lookup

Status: upstream: reported on 2025/08/28 20:30
Reported-by: syzbot+d2c716154e2b0b6081fd@syzkaller.appspotmail.com
First crash: 2d04h, last: 1h27m
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Read in __xfrm_state_lookup (3) net 17 1 1402d 1402d 0/29 closed as invalid on 2021/12/14 20:12
upstream KASAN: slab-out-of-bounds Read in __xfrm_state_lookup (4) net 17 1 1044d 1044d 0/29 closed as invalid on 2022/12/01 17:02

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in __xfrm_state_lookup+0x6b2/0x8d0 net/xfrm/xfrm_state.c:1084
Read of size 2 at addr ffff8880600f3522 by task syz.0.2062/13898

CPU: 0 PID: 13898 Comm: syz.0.2062 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x230 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xac/0x220 mm/kasan/report.c:468
 kasan_report+0x117/0x150 mm/kasan/report.c:581
 __xfrm_state_lookup+0x6b2/0x8d0 net/xfrm/xfrm_state.c:1084
 xfrm_state_lookup+0xef/0x1a0 net/xfrm/xfrm_state.c:2042
 xfrm_input+0x3d62/0x6a20 net/xfrm/xfrm_input.c:575
 xfrm4_rcv_encap+0x38f/0x600 net/ipv4/xfrm4_protocol.c:84
 udp_queue_rcv_one_skb+0x1603/0x1820 net/ipv4/udp.c:2131
 __udp4_lib_mcast_deliver+0xc47/0xd30 net/ipv4/udp.c:2301
 __udp4_lib_rcv+0x10bf/0x2430 net/ipv4/udp.c:2440
 ip_protocol_deliver_rcu+0x20e/0x3f0 net/ipv4/ip_input.c:205
 ip_local_deliver_finish+0x2ca/0x510 net/ipv4/ip_input.c:233
 NF_HOOK+0x303/0x390 include/linux/netfilter.h:304
 NF_HOOK+0x303/0x390 include/linux/netfilter.h:304
 __netif_receive_skb_one_core net/core/dev.c:5608 [inline]
 __netif_receive_skb+0xcc/0x290 net/core/dev.c:5722
 netif_receive_skb_internal net/core/dev.c:5808 [inline]
 netif_receive_skb+0x1bc/0x6f0 net/core/dev.c:5867
 tun_rx_batched+0x1ba/0x730 drivers/net/tun.c:1556
 tun_get_user+0x283f/0x3bf0 drivers/net/tun.c:2009
 tun_chr_write_iter+0x119/0x200 drivers/net/tun.c:2055
 call_write_iter include/linux/fs.h:2018 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x43b/0x940 fs/read_write.c:584
 ksys_write+0x147/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f14b978d69f
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 f9 92 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 4c 93 02 00 48
RSP: 002b:00007f14ba5cf000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f14b99c5fa0 RCX: 00007f14b978d69f
RDX: 00000000000000be RSI: 00002000000014c0 RDI: 00000000000000c8
RBP: 00007f14b9811e19 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000000000be R11: 0000000000000293 R12: 0000000000000000
R13: 00007f14b99c6038 R14: 00007f14b99c5fa0 R15: 00007ffd5aa5f4c8
 </TASK>

Allocated by task 12897:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4e/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6e/0x4d0 mm/slab.h:767
 slab_alloc_node mm/slub.c:3485 [inline]
 slab_alloc mm/slub.c:3493 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3500 [inline]
 kmem_cache_alloc+0x11e/0x2e0 mm/slub.c:3509
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 xfrm_state_alloc+0x22/0x2a0 net/xfrm/xfrm_state.c:661
 __find_acq_core+0x7d8/0x19d0 net/xfrm/xfrm_state.c:1598
 xfrm_find_acq+0x6a/0x90 net/xfrm/xfrm_state.c:2070
 pfkey_getspi+0x64f/0xed0 net/key/af_key.c:1365
 pfkey_process net/key/af_key.c:2847 [inline]
 pfkey_sendmsg+0xbed/0x1050 net/key/af_key.c:3698
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 ____sys_sendmsg+0x5bf/0x950 net/socket.c:2595
 ___sys_sendmsg+0x220/0x290 net/socket.c:2649
 __sys_sendmsg net/socket.c:2678 [inline]
 __do_sys_sendmsg net/socket.c:2687 [inline]
 __se_sys_sendmsg+0x1a5/0x270 net/socket.c:2685
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff8880600f3400
 which belongs to the cache xfrm_state of size 848
The buggy address is located 290 bytes inside of
 freed 848-byte region [ffff8880600f3400, ffff8880600f3750)

The buggy address belongs to the physical page:
page:ffffea0001803c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880600f3000 pfn:0x600f0
head:ffffea0001803c00 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff88801a6e3500 dead000000000122 0000000000000000
raw: ffff8880600f3000 0000000080100007 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x152820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL), pid 9173, tgid 9169 (syz.4.812), ts 490479461108, free_ts 490013629813
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1cd/0x210 mm/page_alloc.c:1554
 prep_new_page mm/page_alloc.c:1561 [inline]
 get_page_from_freelist+0x195c/0x19f0 mm/page_alloc.c:3191
 __alloc_pages+0x1e3/0x460 mm/page_alloc.c:4457
 alloc_slab_page+0x5d/0x170 mm/slub.c:1876
 allocate_slab mm/slub.c:2023 [inline]
 new_slab+0x87/0x2e0 mm/slub.c:2076
 ___slab_alloc+0xc6d/0x12f0 mm/slub.c:3230
 __slab_alloc mm/slub.c:3329 [inline]
 __slab_alloc_node mm/slub.c:3382 [inline]
 slab_alloc_node mm/slub.c:3475 [inline]
 slab_alloc mm/slub.c:3493 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3500 [inline]
 kmem_cache_alloc+0x1b7/0x2e0 mm/slub.c:3509
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 xfrm_state_alloc+0x22/0x2a0 net/xfrm/xfrm_state.c:661
 xfrm_state_find+0x2944/0x4510 net/xfrm/xfrm_state.c:1303
 xfrm_tmpl_resolve_one net/xfrm/xfrm_policy.c:2502 [inline]
 xfrm_tmpl_resolve net/xfrm/xfrm_policy.c:2547 [inline]
 xfrm_resolve_and_create_bundle+0x727/0x2c20 net/xfrm/xfrm_policy.c:2841
 xfrm_lookup_with_ifid+0x261/0x19c0 net/xfrm/xfrm_policy.c:3175
 xfrm_lookup net/xfrm/xfrm_policy.c:3304 [inline]
 xfrm_lookup_route+0x3c/0x1b0 net/xfrm/xfrm_policy.c:3315
 udp_sendmsg+0x15cf/0x2380 net/ipv4/udp.c:1236
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 ____sys_sendmsg+0x5bf/0x950 net/socket.c:2595
 ___sys_sendmsg+0x220/0x290 net/socket.c:2649
 __sys_sendmmsg+0x275/0x4a0 net/socket.c:2735
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1154 [inline]
 free_unref_page_prepare+0x7ce/0x8e0 mm/page_alloc.c:2336
 free_unref_page+0x32/0x2e0 mm/page_alloc.c:2429
 discard_slab mm/slub.c:2122 [inline]
 __unfreeze_partials+0x1cf/0x210 mm/slub.c:2662
 put_cpu_partial+0x17c/0x250 mm/slub.c:2738
 __slab_free+0x31d/0x410 mm/slub.c:3686
 qlink_free mm/kasan/quarantine.c:166 [inline]
 qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x143/0x160 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6e/0x4d0 mm/slab.h:767
 slab_alloc_node mm/slub.c:3485 [inline]
 slab_alloc mm/slub.c:3493 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3500 [inline]
 kmem_cache_alloc+0x11e/0x2e0 mm/slub.c:3509
 ptlock_alloc+0x20/0x70 mm/memory.c:6155
 ptlock_init include/linux/mm.h:2909 [inline]
 pagetable_pte_ctor include/linux/mm.h:2932 [inline]
 __pte_alloc_one include/asm-generic/pgalloc.h:71 [inline]
 pte_alloc_one+0xce/0x540 arch/x86/mm/pgtable.c:33
 do_fault_around mm/memory.c:4567 [inline]
 do_read_fault mm/memory.c:4606 [inline]
 do_fault mm/memory.c:4753 [inline]
 do_pte_missing mm/memory.c:3688 [inline]
 handle_pte_fault mm/memory.c:5025 [inline]
 __handle_mm_fault mm/memory.c:5166 [inline]
 handle_mm_fault+0x2e8e/0x4920 mm/memory.c:5331
 do_user_addr_fault+0xad0/0x12e0 arch/x86/mm/fault.c:1324
 handle_page_fault arch/x86/mm/fault.c:1465 [inline]
 exc_page_fault+0x67/0x110 arch/x86/mm/fault.c:1521
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:608

Memory state around the buggy address:
 ffff8880600f3400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880600f3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880600f3500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8880600f3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880600f3600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/30 23:26 linux-6.6.y cc1a1c5b404a 807a3b61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/30 01:50 linux-6.6.y cc1a1c5b404a 807a3b61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/30 01:48 linux-6.6.y cc1a1c5b404a 807a3b61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/29 23:36 linux-6.6.y cc1a1c5b404a 807a3b61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/29 23:26 linux-6.6.y cc1a1c5b404a 807a3b61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/29 09:56 linux-6.6.y cc1a1c5b404a 3e1beec6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/29 09:43 linux-6.6.y cc1a1c5b404a 3e1beec6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
2025/08/28 20:30 linux-6.6.y cc1a1c5b404a d401b9d7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in __xfrm_state_lookup
* Struck through repros no longer work on HEAD.