syzbot


KASAN: use-after-free Read in kernfs_get

Status: upstream: reported on 2024/08/15 10:42
Reported-by: syzbot+b28bdab5e16fa8be1352@syzkaller.appspotmail.com
First crash: 61d, last: 61d
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in kernfs_get kernfs 8 824d 946d 0/28 auto-obsoleted due to no activity on 2022/11/11 09:18
android-5-15 KASAN: use-after-free Read in kernfs_get (2) 6 5h48m 92d 0/2 premoderation: reported on 2024/07/15 05:15
upstream KASAN: use-after-free Read in kernfs_get (2) kernfs 2 607d 693d 0/28 auto-obsoleted due to no activity on 2023/06/16 19:32
android-5-15 KASAN: use-after-free Read in kernfs_get 3 604d 728d 0/2 auto-obsoleted due to no activity on 2023/05/20 22:47
android-6-1 KASAN: use-after-free Read in kernfs_get 2 63d 109d 0/2 premoderation: reported on 2024/06/28 18:32
upstream KASAN: slab-use-after-free Read in kernfs_get kernfs 1 242d 242d 0/28 auto-obsoleted due to no activity on 2024/05/26 00:41
android-5-15 KASAN: use-after-free Write in kernfs_get 3 358d 445d 0/2 auto-obsoleted due to no activity on 2024/01/21 14:31

Sample crash report:
usb 1-1: Direct firmware load for ueagle-atm/adi930.fw failed with error -2
usb 1-1: Falling back to sysfs fallback for: ueagle-atm/adi930.fw
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in kernfs_get+0x1c/0x90 fs/kernfs/dir.c:504
Read of size 4 at addr ffff8880640679f8 by task kworker/0:7/3629

CPU: 0 PID: 3629 Comm: kworker/0:7 Not tainted 5.15.164-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Workqueue: events request_firmware_work_func
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:71 [inline]
 atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
 kernfs_get+0x1c/0x90 fs/kernfs/dir.c:504
 sysfs_get include/linux/sysfs.h:635 [inline]
 create_dir lib/kobject.c:111 [inline]
 kobject_add_internal+0x886/0xe00 lib/kobject.c:263
 kobject_add_varg lib/kobject.c:398 [inline]
 kobject_add+0x14e/0x210 lib/kobject.c:450
 class_dir_create_and_add drivers/base/core.c:2966 [inline]
 get_device_parent+0x391/0x400 drivers/base/core.c:3021
 device_add+0x336/0xfd0 drivers/base/core.c:3333
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:507 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:583 [inline]
 firmware_fallback_sysfs+0x3f0/0xc90 drivers/base/firmware_loader/fallback.c:659
 _request_firmware+0xbb1/0x1200 drivers/base/firmware_loader/main.c:848
 request_firmware_work_func+0x126/0x270 drivers/base/firmware_loader/main.c:1097
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 3629:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __kernfs_new_node+0xdb/0x750 fs/kernfs/dir.c:593
 kernfs_new_node+0x136/0x230 fs/kernfs/dir.c:669
 kernfs_create_dir_ns+0x3f/0x120 fs/kernfs/dir.c:1005
 sysfs_create_dir_ns+0x185/0x390 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:89 [inline]
 kobject_add_internal+0x6e0/0xe00 lib/kobject.c:263
 kobject_add_varg lib/kobject.c:398 [inline]
 kobject_add+0x14e/0x210 lib/kobject.c:450
 class_dir_create_and_add drivers/base/core.c:2966 [inline]
 get_device_parent+0x391/0x400 drivers/base/core.c:3021
 device_add+0x336/0xfd0 drivers/base/core.c:3333
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:507 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:583 [inline]
 firmware_fallback_sysfs+0x3f0/0xc90 drivers/base/firmware_loader/fallback.c:659
 _request_firmware+0xbb1/0x1200 drivers/base/firmware_loader/main.c:848
 request_firmware_work_func+0x126/0x270 drivers/base/firmware_loader/main.c:1097
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Freed by task 3659:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
 kernfs_put+0x325/0x4a0 fs/kernfs/dir.c:547
 __kernfs_remove+0x99e/0xc80 fs/kernfs/dir.c:1393
 kernfs_remove+0x1d/0x30 fs/kernfs/dir.c:1406
 __kobject_del+0xe2/0x310 lib/kobject.c:628
 kobject_del+0x41/0x60 lib/kobject.c:651
 device_del+0x9fe/0xbd0 drivers/base/core.c:3612
 usb_disconnect+0x58f/0x8c0 drivers/usb/core/hub.c:2274
 hub_port_connect drivers/usb/core/hub.c:5299 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5595 [inline]
 port_event drivers/usb/core/hub.c:5741 [inline]
 hub_event+0x1d58/0x54c0 drivers/usb/core/hub.c:5823
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 process_scheduled_works kernel/workqueue.c:2373 [inline]
 worker_thread+0xdcf/0x1280 kernel/workqueue.c:2459
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

The buggy address belongs to the object at ffff8880640679f8
 which belongs to the cache kernfs_node_cache of size 168
The buggy address is located 0 bytes inside of
 168-byte region [ffff8880640679f8, ffff888064067aa0)
The buggy address belongs to the page:
page:ffffea00019019c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x64067
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888011df2b40
raw: 0000000000000000 0000000080110011 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 4150, ts 170123063086, free_ts 169269537549
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __kernfs_new_node+0xdb/0x750 fs/kernfs/dir.c:593
 kernfs_new_node+0x136/0x230 fs/kernfs/dir.c:669
 kernfs_create_dir_ns+0x3f/0x120 fs/kernfs/dir.c:1005
 internal_create_group+0x2c2/0xf00 fs/sysfs/group.c:137
 dpm_sysfs_add+0x65/0x270 drivers/base/power/sysfs.c:702
 device_add+0x702/0xfd0 drivers/base/core.c:3369
 netdev_register_kobject+0x176/0x310 net/core/net-sysfs.c:2014
 register_netdevice+0x108c/0x1720 net/core/dev.c:10357
 veth_newlink+0x94f/0xe20 drivers/net/veth.c:1714
 __rtnl_newlink net/core/rtnetlink.c:3501 [inline]
 rtnl_newlink+0x14bd/0x2070 net/core/rtnetlink.c:3549
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5629
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 __vunmap+0x8d4/0xa20 mm/vmalloc.c:2621
 free_work+0x57/0x80 mm/vmalloc.c:95
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
 ffff888064067880: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc
 ffff888064067900: fc fc fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888064067980: fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc fa
                                                                ^
 ffff888064067a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888064067a80: fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/15 10:41 linux-5.15.y 7e89efd3ae1c e4bacdaf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in kernfs_get
* Struck through repros no longer work on HEAD.