syzbot


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

Status: moderation: reported on 2024/08/30 16:06
Subsystems: v9fs
[Documentation on labels]
Reported-by: syzbot+24db89594ec5c7f6c012@syzkaller.appspotmail.com
First crash: 86d, last: 86d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in is_idr lib/radix-tree.c:145 [inline]
BUG: KASAN: slab-use-after-free in delete_node+0x7e0/0x8e0 lib/radix-tree.c:567
Read of size 4 at addr ffff8880257d4108 by task swapper/3/0

CPU: 3 UID: 0 PID: 0 Comm: swapper/3 Not tainted 6.11.0-rc5-syzkaller #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:
 <IRQ>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:119
 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
 is_idr lib/radix-tree.c:145 [inline]
 delete_node+0x7e0/0x8e0 lib/radix-tree.c:567
 __radix_tree_delete+0x193/0x3d0 lib/radix-tree.c:1379
 radix_tree_delete_item+0xeb/0x230 lib/radix-tree.c:1430
 p9_tag_remove net/9p/client.c:398 [inline]
 p9_req_put net/9p/client.c:405 [inline]
 p9_req_put+0xc2/0x250 net/9p/client.c:402
 req_done+0x1e7/0x2f0 net/9p/trans_virtio.c:147
 vring_interrupt drivers/virtio/virtio_ring.c:2595 [inline]
 vring_interrupt+0x31b/0x400 drivers/virtio/virtio_ring.c:2570
 __handle_irq_event_percpu+0x229/0x7c0 kernel/irq/handle.c:158
 handle_irq_event_percpu kernel/irq/handle.c:193 [inline]
 handle_irq_event+0xab/0x1e0 kernel/irq/handle.c:210
 handle_edge_irq+0x263/0xd10 kernel/irq/chip.c:831
 generic_handle_irq_desc include/linux/irqdesc.h:173 [inline]
 handle_irq arch/x86/kernel/irq.c:247 [inline]
 call_irq_handler arch/x86/kernel/irq.c:259 [inline]
 __common_interrupt+0xdf/0x250 arch/x86/kernel/irq.c:285
 common_interrupt+0xab/0xd0 arch/x86/kernel/irq.c:278
 </IRQ>
 <TASK>
 asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:693
RIP: 0010:tick_nohz_idle_exit+0x1c3/0x2e0 kernel/time/tick-sched.c:1472
Code: 85 8e 00 00 00 e8 7d 9c 0e 00 e8 78 9c 0e 00 31 ff 4c 89 e6 e8 de 9e 0e 00 4d 85 e4 75 53 e8 64 9c 0e 00 e8 3f e8 15 00 fb 5b <5d> 41 5c 41 5d c3 cc cc cc cc e8 4e 9c 0e 00 65 44 8b 25 32 ab 86
RSP: 0000:ffffc900001a7df8 EFLAGS: 00000202
RAX: 0000000000053323 RBX: 0000000000000003 RCX: 1ffffffff2025699
RDX: 0000000000000000 RSI: ffffffff8b4cc4a0 RDI: ffffffff8bb09ac0
RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff9012f91f R11: 0000000000000000 R12: 0000000000000000
R13: 00000013b455fd3c R14: ffffffff9012f918 R15: 0000000000000000
 do_idle+0x270/0x3f0 kernel/sched/idle.c:339
 cpu_startup_entry+0x4f/0x60 kernel/sched/idle.c:424
 start_secondary+0x220/0x2b0 arch/x86/kernel/smpboot.c:313
 common_startup_64+0x13e/0x148
 </TASK>

Allocated by task 5605:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kmalloc_noprof include/linux/slab.h:681 [inline]
 p9_client_create+0xcf/0x1210 net/9p/client.c:983
 v9fs_session_init+0x1f8/0x1a80 fs/9p/v9fs.c:410
 v9fs_mount+0xc6/0xa50 fs/9p/vfs_super.c:122
 legacy_get_tree+0x109/0x220 fs/fs_context.c:662
 vfs_get_tree+0x8f/0x380 fs/super.c:1800
 do_new_mount fs/namespace.c:3472 [inline]
 path_mount+0x14e6/0x1f20 fs/namespace.c:3799
 do_mount fs/namespace.c:3812 [inline]
 __do_sys_mount fs/namespace.c:4020 [inline]
 __se_sys_mount fs/namespace.c:3997 [inline]
 __x64_sys_mount+0x294/0x320 fs/namespace.c:3997
 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

Freed by task 5605:
 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+0xf7/0x160 mm/kasan/common.c:240
 __kasan_slab_free+0x32/0x50 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2252 [inline]
 slab_free mm/slub.c:4473 [inline]
 kfree+0x12a/0x3b0 mm/slub.c:4594
 p9_client_create+0xaaa/0x1210 net/9p/client.c:1054
 v9fs_session_init+0x1f8/0x1a80 fs/9p/v9fs.c:410
 v9fs_mount+0xc6/0xa50 fs/9p/vfs_super.c:122
 legacy_get_tree+0x109/0x220 fs/fs_context.c:662
 vfs_get_tree+0x8f/0x380 fs/super.c:1800
 do_new_mount fs/namespace.c:3472 [inline]
 path_mount+0x14e6/0x1f20 fs/namespace.c:3799
 do_mount fs/namespace.c:3812 [inline]
 __do_sys_mount fs/namespace.c:4020 [inline]
 __se_sys_mount fs/namespace.c:3997 [inline]
 __x64_sys_mount+0x294/0x320 fs/namespace.c:3997
 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

The buggy address belongs to the object at ffff8880257d4000
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 264 bytes inside of
 freed 512-byte region [ffff8880257d4000, ffff8880257d4200)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x257d4
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xfdffffff(slab)
raw: 00fff00000000040 ffff888015842c80 0000000000000000 dead000000000001
raw: 0000000000000000 0000000080100010 00000001fdffffff 0000000000000000
head: 00fff00000000040 ffff888015842c80 0000000000000000 dead000000000001
head: 0000000000000000 0000000080100010 00000001fdffffff 0000000000000000
head: 00fff00000000002 ffffea000095f501 ffffffffffffffff 0000000000000000
head: ffff888000000004 0000000000000000 00000000ffffffff 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5340, tgid 5340 (syz-executor), ts 70827219865, free_ts 70660929054
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1493
 prep_new_page mm/page_alloc.c:1501 [inline]
 get_page_from_freelist+0x1351/0x2e50 mm/page_alloc.c:3439
 __alloc_pages_noprof+0x22b/0x2460 mm/page_alloc.c:4695
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x4e/0xf0 mm/slub.c:2321
 allocate_slab mm/slub.c:2484 [inline]
 new_slab+0x84/0x260 mm/slub.c:2537
 ___slab_alloc+0xdac/0x1870 mm/slub.c:3723
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3813
 __slab_alloc_node mm/slub.c:3866 [inline]
 slab_alloc_node mm/slub.c:4025 [inline]
 __do_kmalloc_node mm/slub.c:4157 [inline]
 __kmalloc_noprof+0x367/0x400 mm/slub.c:4170
 kmalloc_noprof include/linux/slab.h:685 [inline]
 kzalloc_noprof include/linux/slab.h:807 [inline]
 fib6_info_alloc+0x40/0x160 net/ipv6/ip6_fib.c:155
 ip6_route_info_create+0x337/0x1910 net/ipv6/route.c:3761
 ip6_route_add+0x26/0x1c0 net/ipv6/route.c:3853
 addrconf_add_mroute+0x1de/0x350 net/ipv6/addrconf.c:2550
 addrconf_add_dev+0x14e/0x1c0 net/ipv6/addrconf.c:2568
 inet6_addr_add+0x1a8/0xbc0 net/ipv6/addrconf.c:3024
 inet6_rtm_newaddr+0x11d1/0x1aa0 net/ipv6/addrconf.c:5048
 rtnetlink_rcv_msg+0x3c7/0xea0 net/core/rtnetlink.c:6647
page last free pid 5351 tgid 5351 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1094 [inline]
 free_unref_page+0x64a/0xe40 mm/page_alloc.c:2612
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3988 [inline]
 slab_alloc_node mm/slub.c:4037 [inline]
 kmem_cache_alloc_node_noprof+0x153/0x310 mm/slub.c:4080
 __alloc_skb+0x2b1/0x380 net/core/skbuff.c:664
 alloc_skb include/linux/skbuff.h:1320 [inline]
 netlink_alloc_large_skb+0x69/0x130 net/netlink/af_netlink.c:1206
 netlink_sendmsg+0x689/0xd70 net/netlink/af_netlink.c:1876
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 __sys_sendto+0x47f/0x4e0 net/socket.c:2204
 __do_sys_sendto net/socket.c:2216 [inline]
 __se_sys_sendto net/socket.c:2212 [inline]
 __x64_sys_sendto+0xe0/0x1c0 net/socket.c:2212
 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:
 ffff8880257d4000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880257d4080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880257d4100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8880257d4180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880257d4200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
----------------
Code disassembly (best guess), 1 bytes skipped:
   0:	8e 00                	mov    (%rax),%es
   2:	00 00                	add    %al,(%rax)
   4:	e8 7d 9c 0e 00       	call   0xe9c86
   9:	e8 78 9c 0e 00       	call   0xe9c86
   e:	31 ff                	xor    %edi,%edi
  10:	4c 89 e6             	mov    %r12,%rsi
  13:	e8 de 9e 0e 00       	call   0xe9ef6
  18:	4d 85 e4             	test   %r12,%r12
  1b:	75 53                	jne    0x70
  1d:	e8 64 9c 0e 00       	call   0xe9c86
  22:	e8 3f e8 15 00       	call   0x15e866
  27:	fb                   	sti
  28:	5b                   	pop    %rbx
* 29:	5d                   	pop    %rbp <-- trapping instruction
  2a:	41 5c                	pop    %r12
  2c:	41 5d                	pop    %r13
  2e:	c3                   	ret
  2f:	cc                   	int3
  30:	cc                   	int3
  31:	cc                   	int3
  32:	cc                   	int3
  33:	e8 4e 9c 0e 00       	call   0xe9c86
  38:	65                   	gs
  39:	44                   	rex.R
  3a:	8b                   	.byte 0x8b
  3b:	25                   	.byte 0x25
  3c:	32                   	.byte 0x32
  3d:	ab                   	stos   %eax,%es:(%rdi)
  3e:	86                   	.byte 0x86

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/26 16:00 upstream 5be63fc19fca 9aee4e0b .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in delete_node
* Struck through repros no longer work on HEAD.