syzbot


KASAN: use-after-free Read in dev_uevent

Status: premoderation: reported on 2023/07/10 12:35
Reported-by: syzbot+cbc05d69217a06cd8c7a@syzkaller.appspotmail.com
First crash: 142d, last: 37d
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 7d18h 266d 0/3 upstream: reported C repro on 2023/03/07 19:30
android-54 KASAN: use-after-free Read in dev_uevent 4 916d 980d 0/2 auto-closed as invalid on 2021/09/24 00:56
android-54 KASAN: use-after-free Read in dev_uevent (2) 2 758d 764d 0/2 auto-closed as invalid on 2022/03/01 02:09
android-5-10 KASAN: use-after-free Read in dev_uevent 1 741d 741d 0/2 auto-closed as invalid on 2022/02/16 03:05
upstream KASAN: use-after-free Read in dev_uevent kernel syz 54 285d 1258d 24/25 fixed on 2023/02/24 13:50
upstream KASAN: slab-use-after-free Read in dev_uevent kernel C error 48 11h06m 267d 0/25 upstream: reported C repro on 2023/03/07 08:15

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in string_nocheck lib/vsprintf.c:643 [inline]
BUG: KASAN: use-after-free in string+0x218/0x2a0 lib/vsprintf.c:725
Read of size 1 at addr ffff888165bcac00 by task udevd/711

CPU: 1 PID: 711 Comm: udevd Not tainted 6.1.25-syzkaller-00041-g53771c1826da #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 __asan_report_load1_noabort+0x14/0x20 mm/kasan/report_generic.c:348
 string_nocheck lib/vsprintf.c:643 [inline]
 string+0x218/0x2a0 lib/vsprintf.c:725
 vsnprintf+0x11fc/0x1c70 lib/vsprintf.c:2800
 add_uevent_var+0x1c0/0x440 lib/kobject_uevent.c:665
 dev_uevent+0x3ee/0x6f0 drivers/base/core.c:2568
 uevent_show+0x192/0x310 drivers/base/core.c:2639
 dev_attr_show+0x56/0xd0 drivers/base/core.c:2342
 sysfs_kf_seq_show+0x27c/0x3a0 fs/sysfs/file.c:59
 kernfs_seq_show+0x119/0x160 fs/kernfs/file.c:201
 seq_read_iter+0x430/0xd00 fs/seq_file.c:230
 kernfs_fop_read_iter+0x145/0x470 fs/kernfs/file.c:275
 call_read_iter include/linux/fs.h:2209 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x771/0xad0 fs/read_write.c:470
 ksys_read+0x199/0x2c0 fs/read_write.c:613
 __do_sys_read fs/read_write.c:623 [inline]
 __se_sys_read fs/read_write.c:621 [inline]
 __x64_sys_read+0x7b/0x90 fs/read_write.c:621
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f64c9b16b6a
Code: 00 3d 00 00 41 00 75 0d 50 48 8d 3d 2d 08 0a 00 e8 ea 7d 01 00 31 c0 e9 07 ff ff ff 64 8b 04 25 18 00 00 00 85 c0 75 1b 0f 05 <48> 3d 00 f0 ff ff 76 6c 48 8b 15 8f a2 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffcd9d7b718 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00005568f19296f0 RCX: 00007f64c9b16b6a
RDX: 0000000000001000 RSI: 00005568f193c9a0 RDI: 0000000000000008
RBP: 00005568f19296f0 R08: 0000000000000008 R09: 0000000000000004
R10: 000000000000010f R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000003fff R14: 00007ffcd9d7bbf8 R15: 000000000000000a
 </TASK>

Allocated by task 12552:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:379 [inline]
 __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388
 kasan_kmalloc include/linux/kasan.h:212 [inline]
 kmalloc_trace+0x44/0xa0 mm/slab_common.c:1052
 kmalloc include/linux/slab.h:553 [inline]
 raw_ioctl_init drivers/usb/gadget/legacy/raw_gadget.c:460 [inline]
 raw_ioctl+0x1a2d/0x3620 drivers/usb/gadget/legacy/raw_gadget.c:1250
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0x114/0x190 fs/ioctl.c:856
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 12552:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1744 [inline]
 slab_free_freelist_hook mm/slub.c:1770 [inline]
 slab_free mm/slub.c:3681 [inline]
 __kmem_cache_free+0x218/0x3b0 mm/slub.c:3694
 kfree+0x7a/0xf0 mm/slab_common.c:1009
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:210 [inline]
 kref_put+0xb6/0x7c0 include/linux/kref.h:65
 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:424
 __fput+0x3ab/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xbd5/0x2b80 kernel/exit.c:875
 do_group_exit+0x21a/0x2d0 kernel/exit.c:1025
 get_signal+0x169d/0x1820 kernel/signal.c:2875
 arch_do_signal_or_restart+0xb0/0x16f0 arch/x86/kernel/signal.c:869
 exit_to_user_mode_loop+0x6b/0xa0 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:297
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff888165bcac00
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff888165bcac00, ffff888165bcac20)

The buggy address belongs to the physical page:
page:ffffea000596f280 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x165bca
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea00042d7000 dead000000000002 ffff888100042600
raw: 0000000000000000 0000000000400040 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 5694, tgid 5694 (syz-executor.5), ts 265815505093, free_ts 262572292920
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2582
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2589
 get_page_from_freelist+0x2878/0x2910 mm/page_alloc.c:4390
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5672
 allocate_slab mm/slub.c:1959 [inline]
 new_slab+0xce/0x4c0 mm/slub.c:2012
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3200
 __slab_alloc+0x5d/0xa0 mm/slub.c:3299
 slab_alloc_node mm/slub.c:3384 [inline]
 __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3457
 kmalloc_trace+0x2a/0xa0 mm/slab_common.c:1047
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 ref_tracker_alloc+0x138/0x450 lib/ref_tracker.c:85
 __netdev_tracker_alloc include/linux/netdevice.h:4059 [inline]
 netdev_tracker_alloc+0x67/0x90 include/linux/netdevice.h:4071
 fib_create_info+0x18bd/0x1f10 net/ipv4/fib_semantics.c:1547
 fib_table_insert+0x1b7/0x20a0 net/ipv4/fib_trie.c:1236
 fib_magic net/ipv4/fib_frontend.c:1104 [inline]
 fib_add_ifaddr+0x43f/0x15e0 net/ipv4/fib_frontend.c:1126
 fib_netdev_event+0x23f/0x5a0 net/ipv4/fib_frontend.c:1486
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:455
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1494 [inline]
 free_pcp_prepare mm/page_alloc.c:1568 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3486
 free_unref_page+0x8c/0x4a0 mm/page_alloc.c:3582
 free_the_page mm/page_alloc.c:794 [inline]
 free_compound_page+0x9d/0xd0 mm/page_alloc.c:817
 destroy_large_folio+0x56/0x90 mm/page_alloc.c:854
 __folio_put_large mm/swap.c:118 [inline]
 __folio_put+0xcf/0xe0 mm/swap.c:126
 folio_put include/linux/mm.h:1415 [inline]
 put_page include/linux/mm.h:1467 [inline]
 __skb_frag_unref include/linux/skbuff.h:3393 [inline]
 skb_release_data+0x3c1/0x840 net/core/skbuff.c:783
 skb_release_all net/core/skbuff.c:854 [inline]
 __kfree_skb net/core/skbuff.c:868 [inline]
 napi_consume_skb+0x119/0x2d0 net/core/skbuff.c:1107
 skb_defer_free_flush net/core/dev.c:6656 [inline]
 net_rx_action+0x473/0xdd0 net/core/dev.c:6677
 __do_softirq+0x1d8/0x661 kernel/softirq.c:613

Memory state around the buggy address:
 ffff888165bcab00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
 ffff888165bcab80: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
>ffff888165bcac00: fa fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc
                   ^
 ffff888165bcac80: 00 00 00 00 fc fc fc fc fa fb fb fb fc fc fc fc
 ffff888165bcad00: 00 00 00 00 fc fc fc fc 00 00 00 00 fc fc fc fc
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/23 08:57 android14-6.1 53771c1826da 361b23dc .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in dev_uevent
2023/10/02 02:55 android14-6.1 52824b718cd0 8e26a358 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in dev_uevent
2023/08/09 11:35 android14-6.1 960d9828eee1 8ad1a287 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in dev_uevent
2023/07/31 05:17 android14-6.1 d3b37a712ab7 2a0d0f29 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in dev_uevent
2023/07/10 12:34 android14-6.1 0a2e9dd65c6b d47e94ee .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in dev_uevent
* Struck through repros no longer work on HEAD.