syzbot


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

Status: auto-closed as invalid on 2022/03/01 02:09
Reported-by: syzbot+e01385ee938f7de7f712@syzkaller.appspotmail.com
First crash: 944d, last: 938d
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in dev_uevent origin:upstream C 4 26d 446d 0/3 upstream: reported C repro on 2023/03/07 19:30
android-54 KASAN: use-after-free Read in dev_uevent 4 1096d 1160d 0/2 auto-closed as invalid on 2021/09/24 00:56
android-6-1 KASAN: use-after-free Read in dev_uevent 6 151d 322d 0/2 auto-obsoleted due to no activity on 2024/03/27 01:05
android-5-10 KASAN: use-after-free Read in dev_uevent 1 921d 921d 0/2 auto-closed as invalid on 2022/02/16 03:05
upstream KASAN: use-after-free Read in dev_uevent kernel syz 54 465d 1438d 22/26 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Read in dev_uevent kernel C error 68 3d21h 447d 0/26 upstream: reported C repro on 2023/03/07 08:15

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_uevent+0x32c/0x5b0 drivers/base/core.c:1872
Read of size 8 at addr ffff8881e3e16058 by task udevd/155

CPU: 1 PID: 155 Comm: udevd Not tainted 5.4.147-syzkaller-00040-g2138e7367558 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x18e/0x1de lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:384
 __kasan_report+0x182/0x260 mm/kasan/report.c:516
 kasan_report+0x30/0x60 mm/kasan/common.c:653
 dev_uevent+0x32c/0x5b0 drivers/base/core.c:1872
 uevent_show+0x1a2/0x2e0 drivers/base/core.c:1943
 dev_attr_show+0x50/0xc0 drivers/base/core.c:1647
 sysfs_kf_seq_show+0x265/0x3e0 fs/sysfs/file.c:61
 seq_read+0x4ca/0xda0 fs/seq_file.c:232
 __vfs_read+0xa7/0x690 fs/read_write.c:425
 vfs_read+0x161/0x370 fs/read_write.c:461
 ksys_read+0x13f/0x240 fs/read_write.c:587
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f013669f8fe
Code: c0 e9 e6 fe ff ff 50 48 8d 3d 0e c7 09 00 e8 c9 cf 01 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28
RSP: 002b:00007ffc547b3da8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00005624ede03c90 RCX: 00007f013669f8fe
RDX: 0000000000001000 RSI: 00005624ede1e8b0 RDI: 000000000000000c
RBP: 00007f013676c380 R08: 000000000000000c R09: 00007f013676fa60
R10: 0000000000000008 R11: 0000000000000246 R12: 00005624ede03c90
R13: 0000000000000d68 R14: 00007f013676b780 R15: 0000000000000d68

Allocated by task 3994:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529
 kmem_cache_alloc_trace+0x139/0x2b0 mm/slub.c:2849
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 dev_new drivers/usb/gadget/legacy/raw_gadget.c:182 [inline]
 raw_open+0x84/0x370 drivers/usb/gadget/legacy/raw_gadget.c:372
 misc_open+0x346/0x3c0 drivers/char/misc.c:141
 chrdev_open+0x4ec/0x5b0 fs/char_dev.c:414
 do_dentry_open+0x7e6/0xef0 fs/open.c:796
 do_last fs/namei.c:3495 [inline]
 path_openat+0xfed/0x3a50 fs/namei.c:3612
 do_filp_open+0x19a/0x3a0 fs/namei.c:3642
 do_sys_open+0x2e2/0x6d0 fs/open.c:1113
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 3994:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 kasan_set_free_info mm/kasan/common.c:345 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487
 slab_free_hook mm/slub.c:1455 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1493
 slab_free mm/slub.c:3073 [inline]
 kfree+0xe0/0x660 mm/slub.c:4064
 raw_release+0x130/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:411
 __fput+0x27d/0x6c0 fs/file_table.c:281
 task_work_run+0x186/0x1b0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xc0a/0x2aa0 kernel/exit.c:812
 do_group_exit+0x15c/0x2c0 kernel/exit.c:910
 get_signal+0x150f/0x1e00 kernel/signal.c:2745
 do_signal+0x3b/0x580 arch/x86/kernel/signal.c:809
 exit_to_usermode_loop arch/x86/entry/common.c:159 [inline]
 prepare_exit_to_usermode+0x207/0x310 arch/x86/entry/common.c:194
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881e3e16000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 88 bytes inside of
 4096-byte region [ffff8881e3e16000, ffff8881e3e17000)
The buggy address belongs to the page:
page:ffffea00078f8400 refcount:1 mapcount:0 mapping:ffff8881f5c0c280 index:0x0 compound_mapcount: 0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881f5c0c280
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL)
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook mm/page_alloc.c:2165 [inline]
 prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x2d6/0x740 mm/page_alloc.c:4855
 alloc_slab_page+0x39/0x3e0 mm/slub.c:343
 allocate_slab mm/slub.c:1676 [inline]
 new_slab+0x97/0x460 mm/slub.c:1742
 new_slab_objects mm/slub.c:2499 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2660
 __slab_alloc mm/slub.c:2700 [inline]
 slab_alloc_node mm/slub.c:2785 [inline]
 slab_alloc mm/slub.c:2830 [inline]
 kmem_cache_alloc_trace+0x199/0x2b0 mm/slub.c:2847
 kmalloc include/linux/slab.h:556 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 kobject_uevent_env+0x252/0x1000 lib/kobject_uevent.c:524
 device_del+0xe6a/0xf60 drivers/base/core.c:3095
 rollback_registered_many+0xdb3/0x11a0 net/core/dev.c:8630
 rollback_registered net/core/dev.c:8648 [inline]
 unregister_netdevice_queue+0x2bb/0x470 net/core/dev.c:9744
 unregister_netdevice include/linux/netdevice.h:2725 [inline]
 veth_newlink+0x855/0xb00 drivers/net/veth.c:1349
 __rtnl_newlink net/core/rtnetlink.c:3228 [inline]
 rtnl_newlink+0x1313/0x1a80 net/core/rtnetlink.c:3287
 rtnetlink_rcv_msg+0xa3d/0xbb0 net/core/rtnetlink.c:5260
 netlink_rcv_skb+0x1a0/0x3b0 net/netlink/af_netlink.c:2480
 netlink_unicast_kernel net/netlink/af_netlink.c:1305 [inline]
 netlink_unicast+0x7ae/0x910 net/netlink/af_netlink.c:1331
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1176 [inline]
 __free_pages_ok+0xbb6/0xcc0 mm/page_alloc.c:1438
 free_the_page mm/page_alloc.c:4917 [inline]
 __free_pages+0x47/0x1e0 mm/page_alloc.c:4923
 __free_slab+0x237/0x2f0 mm/slub.c:1767
 free_slab mm/slub.c:1782 [inline]
 discard_slab mm/slub.c:1788 [inline]
 unfreeze_partials+0x14f/0x180 mm/slub.c:2280
 put_cpu_partial+0xb5/0x150 mm/slub.c:2316
 __slab_free mm/slub.c:2964 [inline]
 do_slab_free mm/slub.c:3061 [inline]
 ___cache_free+0x352/0x4e0 mm/slub.c:3080
 qlist_free_all mm/kasan/quarantine.c:167 [inline]
 quarantine_reduce+0x17a/0x1e0 mm/kasan/quarantine.c:260
 __kasan_kmalloc+0x43/0x1e0 mm/kasan/common.c:507
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2822 [inline]
 slab_alloc mm/slub.c:2830 [inline]
 __kmalloc+0x140/0x2f0 mm/slub.c:3902
 kmalloc include/linux/slab.h:561 [inline]
 kzalloc include/linux/slab.h:690 [inline]
 fib_create_info+0x1033/0x39b0 net/ipv4/fib_semantics.c:1409
 fib_table_insert+0x19a/0x1b20 net/ipv4/fib_trie.c:1142
 fib_magic net/ipv4/fib_frontend.c:1097 [inline]
 fib_add_ifaddr+0xf61/0x1930 net/ipv4/fib_frontend.c:1141
 fib_netdev_event+0x208/0x6a0 net/ipv4/fib_frontend.c:1478
 notifier_call_chain kernel/notifier.c:98 [inline]
 __raw_notifier_call_chain kernel/notifier.c:399 [inline]
 raw_notifier_call_chain+0x9e/0x110 kernel/notifier.c:406
 __dev_notify_flags+0x1a1/0x3b0 net/core/dev.c:1670
 dev_change_flags+0xe3/0x190 net/core/dev.c:7990

Memory state around the buggy address:
 ffff8881e3e15f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881e3e15f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881e3e16000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff8881e3e16080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881e3e16100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/11/01 02:08 android12-5.4 2138e7367558 098b5d53 .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
2021/10/25 23:43 android12-5.4 eb4a5a5dbd5b c1132b49 .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Read in dev_uevent
* Struck through repros no longer work on HEAD.