syzbot


KASAN: slab-out-of-bounds Read in nsim_dev_health_break_write

Status: internal: reported C repro on 2024/12/14 08:04
Subsystems: net
[Documentation on labels]
Fix commit: ee76746387f6 netdevsim: prevent bad user input in nsim_dev_health_break_write()
Patched on: [ci-qemu-gce-upstream-auto ci-qemu-upstream ci-qemu-upstream-386 ci-qemu2-arm64 ci-qemu2-arm64-compat ci-qemu2-arm64-mte ci-snapshot-upstream-root ci-upstream-gce-leak ci-upstream-kasan-badwrites-root ci-upstream-kasan-gce ci-upstream-kasan-gce-386 ci-upstream-kasan-gce-root ci-upstream-kasan-gce-selinux-root ci-upstream-kasan-gce-smack-root ci-upstream-kmsan-gce-386-root ci-upstream-kmsan-gce-root ci-upstream-linux-next-kasan-gce-root ci-upstream-net-kasan-gce ci-upstream-net-this-kasan-gce ci2-upstream-fs ci2-upstream-kcsan-gce], missing on: [ci-qemu-native-arm64-kvm ci-qemu2-arm32 ci-qemu2-riscv64 ci-upstream-bpf-kasan-gce ci-upstream-bpf-next-kasan-gce ci-upstream-gce-arm64 ci2-upstream-usb]
First crash: 7d06h, last: 2d01h

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in nsim_dev_health_break_write+0x1be/0x1e0 drivers/net/netdevsim/health.c:156
Read of size 1 at addr ffff88801dab4e3f by task syz-executor235/5832

CPU: 1 UID: 0 PID: 5832 Comm: syz-executor235 Not tainted 6.13.0-rc3-syzkaller-00026-g59dbb9d81adf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:489
 kasan_report+0xd9/0x110 mm/kasan/report.c:602
 nsim_dev_health_break_write+0x1be/0x1e0 drivers/net/netdevsim/health.c:156
 full_proxy_write+0xfb/0x1b0 fs/debugfs/file.c:356
 vfs_write+0x24c/0x1150 fs/read_write.c:677
 ksys_write+0x12b/0x250 fs/read_write.c:731
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc33792dd29
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 01 1a 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc90508508 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fc33792dd29
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00000000000f4240 R08: 0000000000000001 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffc90508560
R13: 00007fc33797b3fe R14: 0000000000000003 R15: 00007ffc90508540
 </TASK>

Allocated by task 5477:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __do_kmalloc_node mm/slub.c:4298 [inline]
 __kmalloc_node_track_caller_noprof+0x21d/0x520 mm/slub.c:4317
 __kmemdup_nul mm/util.c:61 [inline]
 kstrdup+0x42/0xb0 mm/util.c:81
 bprm_change_interp+0x78/0xe0 fs/exec.c:1558
 load_script+0x4fd/0x790 fs/binfmt_script.c:125
 search_binary_handler fs/exec.c:1748 [inline]
 exec_binprm fs/exec.c:1790 [inline]
 bprm_execve fs/exec.c:1842 [inline]
 bprm_execve+0x703/0x19b0 fs/exec.c:1818
 do_execveat_common.isra.0+0x4f1/0x630 fs/exec.c:1949
 do_execve fs/exec.c:2023 [inline]
 __do_sys_execve fs/exec.c:2099 [inline]
 __se_sys_execve fs/exec.c:2094 [inline]
 __x64_sys_execve+0x8c/0xb0 fs/exec.c:2094
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5477:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:582
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2353 [inline]
 slab_free mm/slub.c:4613 [inline]
 kfree+0x14f/0x4b0 mm/slub.c:4761
 free_bprm+0x2dd/0x3b0 fs/exec.c:1494
 do_execveat_common.isra.0+0x22a/0x630 fs/exec.c:1951
 do_execve fs/exec.c:2023 [inline]
 __do_sys_execve fs/exec.c:2099 [inline]
 __se_sys_execve fs/exec.c:2094 [inline]
 __x64_sys_execve+0x8c/0xb0 fs/exec.c:2094
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88801dab4e20
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 23 bytes to the right of
 allocated 8-byte region [ffff88801dab4e20, ffff88801dab4e28)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1dab4
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801ac41500 ffffea0000d29e40 dead000000000002
raw: 0000000000000000 0000000080800080 00000001f5000000 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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 1, tgid 1 (swapper/0), ts 3146366555, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1556
 prep_new_page mm/page_alloc.c:1564 [inline]
 get_page_from_freelist+0xfce/0x2f80 mm/page_alloc.c:3474
 __alloc_pages_noprof+0x223/0x25b0 mm/page_alloc.c:4751
 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2269
 alloc_slab_page mm/slub.c:2423 [inline]
 allocate_slab mm/slub.c:2589 [inline]
 new_slab+0x2c9/0x410 mm/slub.c:2642
 ___slab_alloc+0xce2/0x1650 mm/slub.c:3830
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3920
 __slab_alloc_node mm/slub.c:3995 [inline]
 slab_alloc_node mm/slub.c:4156 [inline]
 __do_kmalloc_node mm/slub.c:4297 [inline]
 __kmalloc_node_track_caller_noprof+0x2ee/0x520 mm/slub.c:4317
 __kmemdup_nul mm/util.c:61 [inline]
 kstrdup+0x42/0xb0 mm/util.c:81
 kstrdup_const+0x63/0x80 mm/util.c:101
 acpi_add_id+0x6c/0x230 drivers/acpi/scan.c:1345
 acpi_set_pnp_ids drivers/acpi/scan.c:1417 [inline]
 acpi_init_device_object+0x12b1/0x1980 drivers/acpi/scan.c:1829
 acpi_add_single_object+0xeb/0x1b50 drivers/acpi/scan.c:1880
 acpi_bus_check_add+0x237/0x900 drivers/acpi/scan.c:2181
 acpi_ns_walk_namespace+0x405/0x5b0 drivers/acpi/acpica/nswalk.c:233
 acpi_walk_namespace drivers/acpi/acpica/nsxfeval.c:606 [inline]
 acpi_walk_namespace+0x110/0x130 drivers/acpi/acpica/nsxfeval.c:554
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88801dab4d00: 00 fc fc fc 00 fc fc fc 00 fc fc fc 00 fc fc fc
 ffff88801dab4d80: 00 fc fc fc 00 fc fc fc 00 fc fc fc 07 fc fc fc
>ffff88801dab4e00: 00 fc fc fc fa fc fc fc 01 fc fc fc 00 fc fc fc
                                        ^
 ffff88801dab4e80: 00 fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
 ffff88801dab4f00: fa fc fc fc fa fc fc fc fa fc fc fc fa fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/18 00:08 upstream 59dbb9d81adf a0626d3a .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in nsim_dev_health_break_write
2024/12/14 10:50 upstream a446e965a188 7cbfbb3a .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in nsim_dev_health_break_write
2024/12/19 13:27 upstream eabcdba3ad40 1d58202c .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in nsim_dev_health_break_write
2024/12/14 08:03 upstream 243f750a2df0 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto KASAN: slab-out-of-bounds Read in nsim_dev_health_break_write
* Struck through repros no longer work on HEAD.