syzbot


KASAN: use-after-free Read in kernfs_link_sibling

Status: auto-obsoleted due to no activity on 2022/09/16 07:38
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+f9733d0f30831ee7ab2a@syzkaller.appspotmail.com
First crash: 677d, last: 677d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in kernfs_link_sibling (2) kernfs 1 916d 912d 0/26 auto-closed as invalid on 2021/12/20 10:47
upstream general protection fault in kernfs_link_sibling (3) kernfs 5 441d 441d 0/26 auto-obsoleted due to no activity on 2023/04/09 15:59
upstream general protection fault in kernfs_link_sibling kernfs 1 1025d 1021d 0/26 auto-closed as invalid on 2021/10/02 22:42

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in kernfs_name_compare fs/kernfs/dir.c:317 [inline]
BUG: KASAN: use-after-free in kernfs_sd_compare fs/kernfs/dir.c:331 [inline]
BUG: KASAN: use-after-free in kernfs_link_sibling+0x11e/0x288 fs/kernfs/dir.c:358
Read of size 4 at addr ffffaf800d2d80b0 by task syz-executor.1/3306

CPU: 1 PID: 3306 Comm: syz-executor.1 Not tainted 5.17.0-rc1-syzkaller-00002-g0966d385830d #0
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
[<ffffffff8000a228>] dump_backtrace+0x2e/0x3c arch/riscv/kernel/stacktrace.c:113
[<ffffffff831668cc>] show_stack+0x34/0x40 arch/riscv/kernel/stacktrace.c:119
[<ffffffff831756ba>] __dump_stack lib/dump_stack.c:88 [inline]
[<ffffffff831756ba>] dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:106
[<ffffffff8047479e>] print_address_description.constprop.0+0x2a/0x330 mm/kasan/report.c:255
[<ffffffff80474d4c>] __kasan_report mm/kasan/report.c:442 [inline]
[<ffffffff80474d4c>] kasan_report+0x184/0x1e0 mm/kasan/report.c:459
[<ffffffff804759f4>] check_region_inline mm/kasan/generic.c:183 [inline]
[<ffffffff804759f4>] __asan_load4+0x6e/0x96 mm/kasan/generic.c:255
[<ffffffff8066824e>] kernfs_name_compare fs/kernfs/dir.c:317 [inline]
[<ffffffff8066824e>] kernfs_sd_compare fs/kernfs/dir.c:331 [inline]
[<ffffffff8066824e>] kernfs_link_sibling+0x11e/0x288 fs/kernfs/dir.c:358
[<ffffffff8066ab2e>] kernfs_add_one+0x1ba/0x30e fs/kernfs/dir.c:746
[<ffffffff8066ad6c>] kernfs_create_dir_ns+0xea/0x184 fs/kernfs/dir.c:1004
[<ffffffff80670db0>] sysfs_create_dir_ns+0x10c/0x1ee fs/sysfs/dir.c:59
[<ffffffff80c1be42>] create_dir lib/kobject.c:89 [inline]
[<ffffffff80c1be42>] kobject_add_internal+0x1cc/0x65e lib/kobject.c:255
[<ffffffff80c1cc56>] kobject_add_varg lib/kobject.c:390 [inline]
[<ffffffff80c1cc56>] kobject_add+0x10e/0x1ae lib/kobject.c:442
[<ffffffff813e69a4>] device_add+0x2b0/0x129e drivers/base/core.c:3340
[<ffffffff813e7c82>] device_create_groups_vargs+0x160/0x17e drivers/base/core.c:4062
[<ffffffff813e7d4e>] device_create+0xae/0xe2 drivers/base/core.c:4104
[<ffffffff8039c96e>] bdi_register_va.part.0+0xbe/0x5dc mm/backing-dev.c:881
[<ffffffff8039f308>] bdi_register_va+0x60/0x64 mm/backing-dev.c:905
[<ffffffff804cca52>] super_setup_bdi_name+0xbc/0x17c fs/super.c:1556
[<ffffffff80851734>] fuse_bdi_init fs/fuse/inode.c:1292 [inline]
[<ffffffff80851734>] fuse_fill_super_common+0x370/0x80e fs/fuse/inode.c:1552
[<ffffffff80851d0c>] fuse_fill_super+0x13a/0x18c fs/fuse/inode.c:1628
[<ffffffff804cf7e4>] vfs_get_super fs/super.c:1139 [inline]
[<ffffffff804cf7e4>] get_tree_nodev+0xa8/0x128 fs/super.c:1169
[<ffffffff8084ef2a>] fuse_get_tree+0x198/0x384 fs/fuse/inode.c:1703
[<ffffffff804cc844>] vfs_get_tree+0x4a/0x19c fs/super.c:1497
[<ffffffff80522e36>] do_new_mount fs/namespace.c:2994 [inline]
[<ffffffff80522e36>] path_mount+0xe9c/0x14dc fs/namespace.c:3324
[<ffffffff80524014>] do_mount fs/namespace.c:3337 [inline]
[<ffffffff80524014>] __do_sys_mount fs/namespace.c:3545 [inline]
[<ffffffff80524014>] sys_mount+0x360/0x3ee fs/namespace.c:3522
[<ffffffff80005716>] ret_from_syscall+0x0/0x2

Allocated by task 0:
(stack is not available)

Freed by task 2094:
 stack_trace_save+0xa6/0xd8 kernel/stacktrace.c:122
 kasan_save_stack+0x2c/0x58 mm/kasan/common.c:38
 kasan_set_track+0x1a/0x26 mm/kasan/common.c:45
 kasan_set_free_info+0x1e/0x3a mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x15e/0x180 mm/kasan/common.c:328
 __kasan_slab_free+0x10/0x18 mm/kasan/common.c:374
 kasan_slab_free include/linux/kasan.h:236 [inline]
 slab_free_hook mm/slub.c:1728 [inline]
 slab_free_freelist_hook+0x8e/0x1cc mm/slub.c:1754
 slab_free mm/slub.c:3509 [inline]
 kfree+0xe0/0x3e4 mm/slub.c:4562
 skb_free_head net/core/skbuff.c:655 [inline]
 skb_release_data+0x3c2/0x3c4 net/core/skbuff.c:677
 skb_release_all net/core/skbuff.c:742 [inline]
 __kfree_skb net/core/skbuff.c:756 [inline]
 consume_skb net/core/skbuff.c:914 [inline]
 consume_skb+0x96/0x136 net/core/skbuff.c:908
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:818 [inline]
 nsim_dev_trap_report_work+0x524/0x5e4 drivers/net/netdevsim/dev.c:843
 process_one_work+0x654/0xffe kernel/workqueue.c:2307
 worker_thread+0x360/0x8fa kernel/workqueue.c:2454
 kthread+0x19e/0x1fa kernel/kthread.c:377
 ret_from_exception+0x0/0x10

The buggy address belongs to the object at ffffaf800d2d8000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 176 bytes inside of
 4096-byte region [ffffaf800d2d8000, ffffaf800d2d9000)
The buggy address belongs to the page:
page:ffffaf807a9fdcc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x8d4d8
head:ffffaf807a9fdcc0 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8800010200(slab|head|section=17|node=0|zone=0)
raw: 0000008800010200 0000000000000000 0000000000000122 ffffaf8007202140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
raw: 00000000000007ff
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 2094, ts 1818101189500, free_ts 1817317906900
 __set_page_owner+0x48/0x136 mm/page_owner.c:183
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0xd0/0x10a mm/page_alloc.c:2427
 prep_new_page mm/page_alloc.c:2434 [inline]
 get_page_from_freelist+0x8da/0x12d8 mm/page_alloc.c:4165
 __alloc_pages+0x150/0x3b6 mm/page_alloc.c:5389
 alloc_pages+0x132/0x2a6 mm/mempolicy.c:2271
 alloc_slab_page.constprop.0+0xc2/0xfa mm/slub.c:1799
 allocate_slab mm/slub.c:1944 [inline]
 new_slab+0x76/0x2cc mm/slub.c:2004
 ___slab_alloc+0x56e/0x918 mm/slub.c:3018
 __slab_alloc.constprop.0+0x50/0x8c mm/slub.c:3105
 slab_alloc_node mm/slub.c:3196 [inline]
 __kmalloc_node_track_caller+0x26c/0x362 mm/slub.c:4957
 kmalloc_reserve net/core/skbuff.c:354 [inline]
 __alloc_skb+0xee/0x2e4 net/core/skbuff.c:426
 alloc_skb include/linux/skbuff.h:1158 [inline]
 nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:745 [inline]
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:802 [inline]
 nsim_dev_trap_report_work+0x1c2/0x5e4 drivers/net/netdevsim/dev.c:843
 process_one_work+0x654/0xffe kernel/workqueue.c:2307
 worker_thread+0x360/0x8fa kernel/workqueue.c:2454
 kthread+0x19e/0x1fa kernel/kthread.c:377
 ret_from_exception+0x0/0x10
page last free stack trace:
 __reset_page_owner+0x4a/0xea mm/page_owner.c:142
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1352 [inline]
 free_pcp_prepare+0x29c/0x45e mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3325 [inline]
 free_unref_page+0x6a/0x31e mm/page_alloc.c:3404
 free_the_page mm/page_alloc.c:706 [inline]
 __free_pages+0xe2/0x112 mm/page_alloc.c:5474
 __free_slab+0x122/0x27c mm/slub.c:2028
 free_slab mm/slub.c:2043 [inline]
 discard_slab+0x4c/0x7a mm/slub.c:2049
 __slab_free+0x20a/0x29c mm/slub.c:3414
 do_slab_free mm/slub.c:3497 [inline]
 ___cache_free+0x17c/0x354 mm/slub.c:3516
 qlink_free mm/kasan/quarantine.c:157 [inline]
 qlist_free_all+0x7c/0x132 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x14c/0x1c8 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x5c/0x98 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:260 [inline]
 slab_post_alloc_hook mm/slab.h:732 [inline]
 slab_alloc_node mm/slub.c:3230 [inline]
 slab_alloc mm/slub.c:3238 [inline]
 kmem_cache_alloc+0x338/0x3de mm/slub.c:3243
 kmem_cache_zalloc include/linux/slab.h:705 [inline]
 alloc_buffer_head+0x28/0x148 fs/buffer.c:3310
 alloc_page_buffers+0x2ac/0x5be fs/buffer.c:832
 grow_dev_page fs/buffer.c:968 [inline]
 grow_buffers fs/buffer.c:1014 [inline]
 __getblk_slow+0x388/0x738 fs/buffer.c:1041
 __getblk_gfp+0x74/0x78 fs/buffer.c:1334

Memory state around the buggy address:
 ffffaf800d2d7f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffffaf800d2d8000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffffaf800d2d8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                     ^
 ffffaf800d2d8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffffaf800d2d8180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Unable to handle kernel access to user memory without uaccess routines at virtual address 0000000000000008
Oops [#1]
Modules linked in:
CPU: 1 PID: 3306 Comm: syz-executor.1 Tainted: G    B             5.17.0-rc1-syzkaller-00002-g0966d385830d #0
Hardware name: riscv-virtio,qemu (DT)
epc : __rb_insert lib/rbtree.c:115 [inline]
epc : rb_insert_color+0x48/0x246 lib/rbtree.c:436
 ra : __rb_insert lib/rbtree.c:115 [inline]
 ra : rb_insert_color+0x48/0x246 lib/rbtree.c:436
epc : ffffffff80c26304 ra : ffffffff80c26304 sp : ffffaf800e703240
 gp : ffffffff85863ac0 tp : ffffaf800bf41840 t0 : 0000000000000000
 t1 : 0000000000006000 t2 : 00007fffffe501b7 s0 : ffffaf800e703280
 s1 : ffffaf800d2d8090 a0 : 0000000000000000 a1 : 0000000000000008
 a2 : 0000000000000000 a3 : ffffffff80c26304 a4 : ffffffff85892ec8
 a5 : 0000000000000001 a6 : 0000000000f00000 a7 : ffffaf805a9e44c7
 s2 : 0000000000000000 s3 : ffffaf800d9e2128 s4 : ffffaf800d2d8098
 s5 : ffffaf800d2c27b0 s6 : 0000000000000000 s7 : ffffaf800d9e2118
 s8 : ffffaf800d83f1e0 s9 : 0000000000000000 s10: ffffaf800d9e2140
 s11: ffffaf800ed24f40 t3 : 000000007fffffff t4 : fffff5ef0b53c898
 t5 : fffff5ef0b53c899 t6 : 0000000000040000
status: 0000000000000120 badaddr: 0000000000000008 cause: 000000000000000d
[<ffffffff80668300>] kernfs_link_sibling+0x1d0/0x288 fs/kernfs/dir.c:369
[<ffffffff8066ab2e>] kernfs_add_one+0x1ba/0x30e fs/kernfs/dir.c:746
[<ffffffff8066ad6c>] kernfs_create_dir_ns+0xea/0x184 fs/kernfs/dir.c:1004
[<ffffffff80670db0>] sysfs_create_dir_ns+0x10c/0x1ee fs/sysfs/dir.c:59
[<ffffffff80c1be42>] create_dir lib/kobject.c:89 [inline]
[<ffffffff80c1be42>] kobject_add_internal+0x1cc/0x65e lib/kobject.c:255
[<ffffffff80c1cc56>] kobject_add_varg lib/kobject.c:390 [inline]
[<ffffffff80c1cc56>] kobject_add+0x10e/0x1ae lib/kobject.c:442
[<ffffffff813e69a4>] device_add+0x2b0/0x129e drivers/base/core.c:3340
[<ffffffff813e7c82>] device_create_groups_vargs+0x160/0x17e drivers/base/core.c:4062
[<ffffffff813e7d4e>] device_create+0xae/0xe2 drivers/base/core.c:4104
[<ffffffff8039c96e>] bdi_register_va.part.0+0xbe/0x5dc mm/backing-dev.c:881
[<ffffffff8039f308>] bdi_register_va+0x60/0x64 mm/backing-dev.c:905
[<ffffffff804cca52>] super_setup_bdi_name+0xbc/0x17c fs/super.c:1556
[<ffffffff80851734>] fuse_bdi_init fs/fuse/inode.c:1292 [inline]
[<ffffffff80851734>] fuse_fill_super_common+0x370/0x80e fs/fuse/inode.c:1552
[<ffffffff80851d0c>] fuse_fill_super+0x13a/0x18c fs/fuse/inode.c:1628
[<ffffffff804cf7e4>] vfs_get_super fs/super.c:1139 [inline]
[<ffffffff804cf7e4>] get_tree_nodev+0xa8/0x128 fs/super.c:1169
[<ffffffff8084ef2a>] fuse_get_tree+0x198/0x384 fs/fuse/inode.c:1703
[<ffffffff804cc844>] vfs_get_tree+0x4a/0x19c fs/super.c:1497
[<ffffffff80522e36>] do_new_mount fs/namespace.c:2994 [inline]
[<ffffffff80522e36>] path_mount+0xe9c/0x14dc fs/namespace.c:3324
[<ffffffff80524014>] do_mount fs/namespace.c:3337 [inline]
[<ffffffff80524014>] __do_sys_mount fs/namespace.c:3545 [inline]
[<ffffffff80524014>] sys_mount+0x360/0x3ee fs/namespace.c:3522
[<ffffffff80005716>] ret_from_syscall+0x0/0x2
---[ end trace 0000000000000000 ]---

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/06/18 07:38 git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes 0966d385830d 8f633d84 .config console log report info ci-qemu2-riscv64 KASAN: use-after-free Read in kernfs_link_sibling
* Struck through repros no longer work on HEAD.