syzbot


KASAN: invalid-free in raw_release

Status: premoderation: reported on 2024/11/15 06:17
Reported-by: syzbot+ff802676c112ee960500@syzkaller.appspotmail.com
First crash: 6d10h, last: 6d10h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: invalid-free in raw_release 3 48d 85d 0/3 upstream: reported on 2024/08/28 08:13
upstream KASAN: invalid-free in raw_release usb 23 22d 96d 0/28 closed as dup on 2024/09/21 21:01

Sample crash report:
==================================================================
BUG: KASAN: double-free in kfree+0x7a/0xf0 mm/slab_common.c:990
Free of addr ffff8881094aed20 by task syz.4.287/1013

CPU: 1 PID: 1013 Comm: syz.4.287 Not tainted 6.1.112-syzkaller-00014-g7160754546da #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
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_invalid_free+0xea/0x110 mm/kasan/report.c:496
 ____kasan_slab_free+0x14e/0x180
 __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:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697
 kfree+0x7a/0xf0 mm/slab_common.c:990
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:224 [inline]
 kref_put+0x4ac/0x7c0 include/linux/kref.h:65
 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:426
 __fput+0x1e5/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:203
 exit_task_work include/linux/task_work.h:39 [inline]
 do_exit+0xbd5/0x2b80 kernel/exit.c:877
 do_group_exit+0x21a/0x2d0 kernel/exit.c:1027
 get_signal+0x169d/0x1820 kernel/signal.c:2888
 arch_do_signal_or_restart+0xb0/0x16f0 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x74/0xa0 kernel/entry/common.c:174
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f78e797d3aa
Code: Unable to access opcode bytes at 0x7f78e797d380.
RSP: 002b:00007f78e8789ff0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 00007f78e7b35f80 RCX: 00007f78e797d3aa
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f78e79f175e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f78e7b35f80 R15: 00007ffe71d7f7d8
 </TASK>

Allocated by task 1036:
 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]
 __do_kmalloc_node mm/slab_common.c:938 [inline]
 __kmalloc_node_track_caller+0xb3/0x1e0 mm/slab_common.c:958
 memdup_user+0x2a/0xc0 mm/util.c:179
 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:801 [inline]
 raw_ioctl+0x641/0x3620 drivers/usb/gadget/legacy/raw_gadget.c:1273
 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
 x64_sys_call+0x98/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 1013:
 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:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697
 kfree+0x7a/0xf0 mm/slab_common.c:990
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:224 [inline]
 kref_put+0x4ac/0x7c0 include/linux/kref.h:65
 raw_release+0x145/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:426
 __fput+0x1e5/0x870 fs/file_table.c:320
 ____fput+0x15/0x20 fs/file_table.c:348
 task_work_run+0x24d/0x2e0 kernel/task_work.c:203
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x26/0x130 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

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

The buggy address belongs to the physical page:
page:ffffea0004252b80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1094ae
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea0004398c80 dead000000000002 ffff888100042480
raw: 0000000000000000 0000000000800080 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 1, tgid 1 (swapper/0), ts 1207673021, free_ts 0
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x2980/0x2a10 mm/page_alloc.c:4439
 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460
 __do_kmalloc_node mm/slab_common.c:937 [inline]
 __kmalloc+0xa3/0x1e0 mm/slab_common.c:951
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 kobject_get_path+0xbf/0x210 lib/kobject.c:152
 kobject_uevent_env+0x27c/0x720 lib/kobject_uevent.c:544
 kobject_uevent+0x1f/0x30 lib/kobject_uevent.c:657
 kernel_add_sysfs_param+0x108/0x12d kernel/params.c:816
 param_sysfs_builtin+0x210/0x2b5 kernel/params.c:851
 param_sysfs_init+0x6a/0x6f kernel/params.c:970
page_owner free stack trace missing

Memory state around the buggy address:
 ffff8881094aec00: 00 01 fc fc 00 00 fc fc 00 03 fc fc fa fb fc fc
 ffff8881094aec80: 00 00 fc fc fa fb fc fc 00 00 fc fc 00 05 fc fc
>ffff8881094aed00: 00 00 fc fc fa fb fc fc 00 03 fc fc fa fb fc fc
                               ^
 ffff8881094aed80: fa fb fc fc 00 04 fc fc 00 02 fc fc 00 00 fc fc
 ffff8881094aee00: 00 00 fc fc fa fb fc fc 00 01 fc fc 00 01 fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/15 06:16 android14-6.1 7160754546da f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: invalid-free in raw_release
* Struck through repros no longer work on HEAD.