syzbot


KASAN: use-after-free Read in kernfs_get

Status: auto-obsoleted due to no activity on 2022/11/11 09:18
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+97a16334dbd58916f7fb@syzkaller.appspotmail.com
First crash: 1022d, last: 853d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in kernfs_get 2 (3) 2022/03/14 17:03
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-15 KASAN: use-after-free Read in kernfs_get (2) 7 3d04h 121d 0/2 premoderation: reported on 2024/07/15 05:15
upstream KASAN: use-after-free Read in kernfs_get (2) kernfs 2 635d 721d 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 632d 756d 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 92d 137d 0/2 auto-obsoleted due to no activity on 2024/11/11 11:50
linux-5.15 KASAN: use-after-free Read in kernfs_get 1 90d 90d 0/3 upstream: reported on 2024/08/15 10:42
upstream KASAN: slab-use-after-free Read in kernfs_get kernfs 1 271d 271d 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 386d 474d 0/2 auto-obsoleted due to no activity on 2024/01/21 14:31

Sample crash report:
usb 4-1: Direct firmware load for ueagle-atm/adi930.fw failed with error -2
usb 4-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.part.0+0x17/0x80 fs/kernfs/dir.c:504
Read of size 4 at addr ffff88807d5e1000 by task kworker/0:2/142

CPU: 0 PID: 142 Comm: kworker/0:2 Not tainted 5.19.0-rc6-syzkaller-00115-g4a57a8400075 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
Workqueue: events request_firmware_work_func
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x467 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0x13d/0x180 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.part.0+0x17/0x80 fs/kernfs/dir.c:504
 kernfs_get+0x1b/0x30 fs/kernfs/dir.c:503
 sysfs_get include/linux/sysfs.h:635 [inline]
 create_dir lib/kobject.c:79 [inline]
 kobject_add_internal+0x35f/0x900 lib/kobject.c:223
 kobject_add_varg lib/kobject.c:358 [inline]
 kobject_add+0x150/0x1c0 lib/kobject.c:410
 class_dir_create_and_add drivers/base/core.c:2965 [inline]
 get_device_parent+0x3d7/0x590 drivers/base/core.c:3020
 device_add+0x2af/0x1ea0 drivers/base/core.c:3349
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:82 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:158 [inline]
 firmware_fallback_sysfs+0x2da/0xbb0 drivers/base/firmware_loader/fallback.c:234
 _request_firmware+0xbd2/0x1190 drivers/base/firmware_loader/main.c:856
 request_firmware_work_func+0xdd/0x230 drivers/base/firmware_loader/main.c:1105
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
 </TASK>

Allocated by task 142:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 __kasan_slab_alloc+0x85/0xb0 mm/kasan/common.c:469
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc mm/slab.c:3302 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3479 [inline]
 kmem_cache_alloc+0x265/0x560 mm/slab.c:3499
 kmem_cache_zalloc include/linux/slab.h:723 [inline]
 __kernfs_new_node+0xd4/0x8b0 fs/kernfs/dir.c:593
 kernfs_new_node fs/kernfs/dir.c:655 [inline]
 kernfs_create_dir_ns+0x9c/0x220 fs/kernfs/dir.c:1010
 sysfs_create_dir_ns+0x127/0x290 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:63 [inline]
 kobject_add_internal+0x2ce/0x900 lib/kobject.c:223
 kobject_add_varg lib/kobject.c:358 [inline]
 kobject_add+0x150/0x1c0 lib/kobject.c:410
 class_dir_create_and_add drivers/base/core.c:2965 [inline]
 get_device_parent+0x3d7/0x590 drivers/base/core.c:3020
 device_add+0x2af/0x1ea0 drivers/base/core.c:3349
 fw_load_sysfs_fallback drivers/base/firmware_loader/fallback.c:82 [inline]
 fw_load_from_user_helper drivers/base/firmware_loader/fallback.c:158 [inline]
 firmware_fallback_sysfs+0x2da/0xbb0 drivers/base/firmware_loader/fallback.c:234
 _request_firmware+0xbd2/0x1190 drivers/base/firmware_loader/main.c:856
 request_firmware_work_func+0xdd/0x230 drivers/base/firmware_loader/main.c:1105
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 worker_thread+0x665/0x1080 kernel/workqueue.c:2436
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Freed by task 3768:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x13d/0x180 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 __cache_free mm/slab.c:3425 [inline]
 kmem_cache_free.part.0+0xa9/0x240 mm/slab.c:3735
 kernfs_put.part.0+0x2c4/0x540 fs/kernfs/dir.c:547
 kernfs_put+0x42/0x50 fs/kernfs/dir.c:521
 __kernfs_remove+0x7a3/0xb20 fs/kernfs/dir.c:1404
 kernfs_remove+0x77/0xa0 fs/kernfs/dir.c:1424
 sysfs_remove_dir+0xc1/0x100 fs/sysfs/dir.c:101
 __kobject_del+0xe2/0x200 lib/kobject.c:588
 kobject_del lib/kobject.c:611 [inline]
 kobject_del+0x3c/0x60 lib/kobject.c:603
 device_del+0x81c/0xc80 drivers/base/core.c:3626
 usb_disconnect.cold+0x4ba/0x6ec drivers/usb/core/hub.c:2254
 hub_port_connect drivers/usb/core/hub.c:5207 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5507 [inline]
 port_event drivers/usb/core/hub.c:5663 [inline]
 hub_event+0x1e83/0x4690 drivers/usb/core/hub.c:5745
 process_one_work+0x996/0x1610 kernel/workqueue.c:2289
 process_scheduled_works kernel/workqueue.c:2352 [inline]
 worker_thread+0x854/0x1080 kernel/workqueue.c:2438
 kthread+0x2e9/0x3a0 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

The buggy address belongs to the object at ffff88807d5e1000
 which belongs to the cache kernfs_node_cache of size 168
The buggy address is located 0 bytes inside of
 168-byte region [ffff88807d5e1000, ffff88807d5e10a8)

The buggy address belongs to the physical page:
page:ffffea0001f57840 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7d5e1
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001f2f708 ffffea00005b68c8 ffff888140165200
raw: 0000000000000000 ffff88807d5e1000 0000000100000011 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 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 3641, tgid 3641 (syz-executor.1), ts 216297914448, free_ts 216294411290
 prep_new_page mm/page_alloc.c:2456 [inline]
 get_page_from_freelist+0x1290/0x3b70 mm/page_alloc.c:4198
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426
 __alloc_pages_node include/linux/gfp.h:587 [inline]
 kmem_getpages mm/slab.c:1363 [inline]
 cache_grow_begin+0x75/0x350 mm/slab.c:2569
 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942
 ____cache_alloc mm/slab.c:3024 [inline]
 ____cache_alloc mm/slab.c:3007 [inline]
 __do_cache_alloc mm/slab.c:3253 [inline]
 slab_alloc mm/slab.c:3295 [inline]
 __kmem_cache_alloc_lru mm/slab.c:3479 [inline]
 kmem_cache_alloc+0x450/0x560 mm/slab.c:3499
 kmem_cache_zalloc include/linux/slab.h:723 [inline]
 __kernfs_new_node+0xd4/0x8b0 fs/kernfs/dir.c:593
 kernfs_new_node+0x93/0x120 fs/kernfs/dir.c:655
 __kernfs_create_file+0x51/0x350 fs/kernfs/file.c:987
 sysfs_add_file_mode_ns+0x20f/0x3f0 fs/sysfs/file.c:294
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x322/0xb10 fs/sysfs/group.c:148
 internal_create_groups.part.0+0x90/0x140 fs/sysfs/group.c:188
 internal_create_groups fs/sysfs/group.c:184 [inline]
 sysfs_create_groups+0x25/0x50 fs/sysfs/group.c:214
 device_add_groups drivers/base/core.c:2483 [inline]
 device_add_attrs drivers/base/core.c:2642 [inline]
 device_add+0x14a6/0x1ea0 drivers/base/core.c:3379
 netdev_register_kobject+0x181/0x400 net/core/net-sysfs.c:2015
 register_netdevice+0xd9d/0x15e0 net/core/dev.c:10047
 veth_newlink+0x4d6/0x9a0 drivers/net/veth.c:1799
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1371 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421
 free_unref_page_prepare mm/page_alloc.c:3343 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3438
 slab_destroy mm/slab.c:1615 [inline]
 slabs_destroy+0x89/0xc0 mm/slab.c:1635
 cache_flusharray mm/slab.c:3397 [inline]
 ___cache_free+0x34e/0x670 mm/slab.c:3460
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x4f/0x1b0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x97/0xb0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc mm/slab.c:3302 [inline]
 kmem_cache_alloc_trace+0x258/0x4a0 mm/slab.c:3567
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 ref_tracker_alloc+0x152/0x560 lib/ref_tracker.c:85
 __netdev_tracker_alloc include/linux/netdevice.h:3960 [inline]
 dev_hold_track include/linux/netdevice.h:3989 [inline]
 dev_hold_track include/linux/netdevice.h:3984 [inline]
 netdev_queue_add_kobject net/core/net-sysfs.c:1663 [inline]
 netdev_queue_update_kobjects+0x1a7/0x4e0 net/core/net-sysfs.c:1718
 register_queue_kobjects net/core/net-sysfs.c:1779 [inline]
 netdev_register_kobject+0x330/0x400 net/core/net-sysfs.c:2019
 register_netdevice+0xd9d/0x15e0 net/core/dev.c:10047
 veth_newlink+0x33f/0x9a0 drivers/net/veth.c:1768
 rtnl_newlink_create net/core/rtnetlink.c:3363 [inline]
 __rtnl_newlink+0x1087/0x17e0 net/core/rtnetlink.c:3580
 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
 rtnetlink_rcv_msg+0x43a/0xc90 net/core/rtnetlink.c:6089

Memory state around the buggy address:
 ffff88807d5e0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807d5e0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807d5e1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88807d5e1080: fb fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb
 ffff88807d5e1100: 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
2022/07/14 09:18 upstream 4a57a8400075 5d921b08 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in kernfs_get
2022/07/11 05:32 upstream d9919d43cbf6 b5765a15 .config console log report info ci-upstream-kasan-gce KASAN: use-after-free Read in kernfs_get
2022/03/14 14:46 upstream 09688c0166e7 9e8eaa75 .config console log report info ci-qemu-upstream KASAN: use-after-free Read in kernfs_get
2022/03/14 13:49 upstream 09688c0166e7 9e8eaa75 .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in kernfs_get
2022/02/20 02:01 upstream 4f12b742eb2b 3cd800e4 .config console log report info ci-upstream-kasan-gce KASAN: use-after-free Read in kernfs_get
2022/01/29 22:07 upstream 169387e2aa29 495e00c5 .config console log report info ci-upstream-kasan-gce-root KASAN: use-after-free Read in kernfs_get
2022/01/29 13:54 upstream 169387e2aa29 495e00c5 .config console log report info ci-upstream-kasan-gce KASAN: use-after-free Read in kernfs_get
2022/01/25 15:45 upstream a08b41ab9e2e 2cbffd88 .config console log report info ci-upstream-kasan-gce KASAN: use-after-free Read in kernfs_get
* Struck through repros no longer work on HEAD.