syzbot


KASAN: use-after-free Read in kernfs_activate (2)

Status: closed as dup on 2022/11/15 06:12
Subsystems: kernfs
[Documentation on labels]
Reported-by: syzbot+782984d6f1701b526edb@syzkaller.appspotmail.com
First crash: 745d, last: 723d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: use-after-free Read in kernfs_next_descendant_post (2) usb kernfs C inconclusive error 54 250d 1145d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in kernfs_activate (2) 2 (3) 2022/11/15 06:12
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in kernfs_activate kernfs 2 986d 993d 0/28 auto-closed as invalid on 2022/07/11 06:54

Sample crash report:
usb 2-1: Direct firmware load for ueagle-atm/eagleI.fw failed with error -2
usb 2-1: Falling back to sysfs fallback for: ueagle-atm/eagleI.fw
==================================================================
BUG: KASAN: use-after-free in kernfs_root fs/kernfs/kernfs-internal.h:66 [inline]
BUG: KASAN: use-after-free in kernfs_next_descendant_post fs/kernfs/dir.c:1299 [inline]
BUG: KASAN: use-after-free in kernfs_activate+0xd0/0x3a0 fs/kernfs/dir.c:1354
Read of size 8 at addr ffff88807dc82bf8 by task kworker/0:4/3710

CPU: 0 PID: 3710 Comm: kworker/0:4 Not tainted 6.1.0-rc7-syzkaller-00102-g04aa64375f48 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Workqueue: events request_firmware_work_func
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x74/0x340 mm/kasan/report.c:284
 print_report+0x107/0x220 mm/kasan/report.c:395
 kasan_report+0x139/0x170 mm/kasan/report.c:495
 kernfs_root fs/kernfs/kernfs-internal.h:66 [inline]
 kernfs_next_descendant_post fs/kernfs/dir.c:1299 [inline]
 kernfs_activate+0xd0/0x3a0 fs/kernfs/dir.c:1354
 kernfs_add_one+0x465/0x560 fs/kernfs/dir.c:786
 kernfs_create_dir_ns+0x1bf/0x220 fs/kernfs/dir.c:1031
 sysfs_create_dir_ns+0x181/0x390 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:63 [inline]
 kobject_add_internal+0x6dd/0xd10 lib/kobject.c:223
 kobject_add_varg lib/kobject.c:358 [inline]
 kobject_add+0x14c/0x210 lib/kobject.c:410
 class_dir_create_and_add drivers/base/core.c:3054 [inline]
 get_device_parent+0x3d5/0x430 drivers/base/core.c:3109
 device_add+0x340/0xf90 drivers/base/core.c:3438
 fw_load_sysfs_fallback+0xd4/0x5e0 drivers/base/firmware_loader/fallback.c:82
 fw_load_from_user_helper+0x12d/0x1f0 drivers/base/firmware_loader/fallback.c:158
 _request_firmware+0x446/0x6a0 drivers/base/firmware_loader/main.c:856
 request_firmware_work_func+0x125/0x270 drivers/base/firmware_loader/main.c:1105
 process_one_work+0x81c/0xd10 kernel/workqueue.c:2289
 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436
 kthread+0x266/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
 </TASK>

Allocated by task 3710:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:325
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slab.h:737 [inline]
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x1cc/0x300 mm/slub.c:3422
 kmem_cache_zalloc include/linux/slab.h:679 [inline]
 __kernfs_new_node+0xdb/0x730 fs/kernfs/dir.c:608
 kernfs_new_node fs/kernfs/dir.c:670 [inline]
 kernfs_create_dir_ns+0x90/0x220 fs/kernfs/dir.c:1021
 sysfs_create_dir_ns+0x181/0x390 fs/sysfs/dir.c:59
 create_dir lib/kobject.c:63 [inline]
 kobject_add_internal+0x6dd/0xd10 lib/kobject.c:223
 kobject_add_varg lib/kobject.c:358 [inline]
 kobject_add+0x14c/0x210 lib/kobject.c:410
 class_dir_create_and_add drivers/base/core.c:3054 [inline]
 get_device_parent+0x3d5/0x430 drivers/base/core.c:3109
 device_add+0x340/0xf90 drivers/base/core.c:3438
 fw_load_sysfs_fallback+0xd4/0x5e0 drivers/base/firmware_loader/fallback.c:82
 fw_load_from_user_helper+0x12d/0x1f0 drivers/base/firmware_loader/fallback.c:158
 _request_firmware+0x446/0x6a0 drivers/base/firmware_loader/main.c:856
 request_firmware_work_func+0x125/0x270 drivers/base/firmware_loader/main.c:1105
 process_one_work+0x81c/0xd10 kernel/workqueue.c:2289
 worker_thread+0xb14/0x1330 kernel/workqueue.c:2436
 kthread+0x266/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Freed by task 7:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:511
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0x94/0x1d0 mm/slub.c:3683
 kernfs_put+0x340/0x490 fs/kernfs/dir.c:562
 __kernfs_remove+0x980/0xa90 fs/kernfs/dir.c:1453
 kernfs_remove+0x76/0x90 fs/kernfs/dir.c:1473
 __kobject_del+0xdc/0x300 lib/kobject.c:588
 kobject_del+0x41/0x60 lib/kobject.c:611
 device_del+0xa10/0xbe0 drivers/base/core.c:3715
 usb_disconnect+0x56e/0x890 drivers/usb/core/hub.c:2261
 hub_port_connect+0x296/0x2910 drivers/usb/core/hub.c:5197
 hub_port_connect_change+0x619/0xbe0 drivers/usb/core/hub.c:5497
 port_event+0xec6/0x13b0 drivers/usb/core/hub.c:5653
 hub_event+0x5c1/0xd80 drivers/usb/core/hub.c:5735
 process_one_work+0x81c/0xd10 kernel/workqueue.c:2289
 process_scheduled_works kernel/workqueue.c:2352 [inline]
 worker_thread+0xe16/0x1330 kernel/workqueue.c:2438
 kthread+0x266/0x300 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

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

The buggy address belongs to the physical page:
page:ffffea0001f72080 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7dc82
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00009e7140 dead000000000007 ffff8880129e0dc0
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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 3661, tgid 3661 (syz-executor.2), ts 215943763394, free_ts 215934915940
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4291
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5558
 alloc_slab_page+0x70/0xf0 mm/slub.c:1794
 allocate_slab+0x5e/0x4b0 mm/slub.c:1939
 new_slab mm/slub.c:1992 [inline]
 ___slab_alloc+0x7f4/0xeb0 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x24c/0x300 mm/slub.c:3422
 kmem_cache_zalloc include/linux/slab.h:679 [inline]
 __kernfs_new_node+0xdb/0x730 fs/kernfs/dir.c:608
 kernfs_new_node+0x95/0x160 fs/kernfs/dir.c:670
 __kernfs_create_file+0x45/0x2e0 fs/kernfs/file.c:1043
 sysfs_add_file_mode_ns+0x21d/0x330 fs/sysfs/file.c:294
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x55c/0xf50 fs/sysfs/group.c:148
 netdev_queue_add_kobject net/core/net-sysfs.c:1672 [inline]
 netdev_queue_update_kobjects+0x22e/0x4c0 net/core/net-sysfs.c:1718
 register_queue_kobjects net/core/net-sysfs.c:1779 [inline]
 netdev_register_kobject+0x263/0x310 net/core/net-sysfs.c:2019
 register_netdevice+0x136c/0x1a20 net/core/dev.c:10057
 veth_newlink+0x638/0xd10 drivers/net/veth.c:1764
 rtnl_newlink_create net/core/rtnetlink.c:3364 [inline]
 __rtnl_newlink net/core/rtnetlink.c:3581 [inline]
 rtnl_newlink+0x14ed/0x2060 net/core/rtnetlink.c:3594
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare+0x80c/0x8f0 mm/page_alloc.c:1509
 free_unref_page_prepare mm/page_alloc.c:3387 [inline]
 free_unref_page+0x7d/0x630 mm/page_alloc.c:3483
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1ab/0x200 mm/slub.c:2586
 put_cpu_partial+0x116/0x180 mm/slub.c:2662
 qlist_free_all+0x2b/0x70 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x169/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:302
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slab.h:737 [inline]
 slab_alloc_node mm/slub.c:3398 [inline]
 __kmem_cache_alloc_node+0x1d7/0x310 mm/slub.c:3437
 kmalloc_trace+0x26/0x60 mm/slab_common.c:1045
 kmalloc include/linux/slab.h:553 [inline]
 rtnl_newlink+0xe6/0x2060 net/core/rtnetlink.c:3590
 rtnetlink_rcv_msg+0x7b8/0xe90 net/core/rtnetlink.c:6091
 netlink_rcv_skb+0x1f0/0x460 net/netlink/af_netlink.c:2540
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x7e7/0x9c0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x9b3/0xcd0 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg net/socket.c:734 [inline]
 __sys_sendto+0x46d/0x5f0 net/socket.c:2117
 __do_sys_sendto net/socket.c:2129 [inline]
 __se_sys_sendto net/socket.c:2125 [inline]
 __x64_sys_sendto+0xda/0xf0 net/socket.c:2125

Memory state around the buggy address:
 ffff88807dc82a80: fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb fb
 ffff88807dc82b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807dc82b80: fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb
                                                                ^
 ffff88807dc82c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff88807dc82c80: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/12/01 06:14 upstream 04aa64375f48 4c2a66e8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in kernfs_activate
2022/11/15 02:47 upstream 094226ad94f4 943f4cb8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in kernfs_activate
2022/11/08 16:52 upstream 59f2f4b8a757 881db35d .config console log report info ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in kernfs_activate
* Struck through repros no longer work on HEAD.