syzbot


KASAN: invalid-free in raw_release

Status: closed as dup on 2024/09/21 21:01
Subsystems: usb
[Documentation on labels]
Reported-by: syzbot+b5e01354ba4aea02654b@syzkaller.appspotmail.com
First crash: 168d, last: 89d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: invalid-free in dev_free usb C 1163 17d 164d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [usb?] KASAN: invalid-free in raw_release 1 (2) 2024/09/21 21:01
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 115d 152d 0/3 auto-obsoleted due to no activity on 2025/01/12 04:20
android-6-1 KASAN: invalid-free in raw_release 1 73d 73d 0/2 premoderation: reported on 2024/11/15 06:17

Sample crash report:
==================================================================
BUG: KASAN: double-free in dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline]
BUG: KASAN: double-free in kref_put+0x4ab/0x7c0 include/linux/kref.h:65
Free of addr ffff888026d9cd00 by task syz.1.13/5957

CPU: 1 UID: 0 PID: 5957 Comm: syz.1.13 Not tainted 6.12.0-rc5-syzkaller-00044-gc1e939a21eb1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report_invalid_free+0x11a/0x140 mm/kasan/report.c:563
 check_slab_allocation+0xc6/0x110
 kasan_slab_pre_free include/linux/kasan.h:195 [inline]
 slab_free_hook mm/slub.c:2287 [inline]
 slab_free mm/slub.c:4579 [inline]
 kfree+0x151/0x440 mm/slub.c:4727
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline]
 kref_put+0x4ab/0x7c0 include/linux/kref.h:65
 raw_release+0x135/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:473
 __fput+0x23f/0x880 fs/file_table.c:431
 task_work_run+0x24f/0x310 kernel/task_work.c:239
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x168/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0e2877e719
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffcabaa7408 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f0e28937a80 RCX: 00007f0e2877e719
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f0e28937a80 R08: 0000000000000000 R09: 00007ffcabaa76ff
R10: 0000000000dbb590 R11: 0000000000000246 R12: 000000000001561b
R13: 00007ffcabaa7510 R14: 0000000000000032 R15: ffffffffffffffff
 </TASK>

Allocated by task 5975:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:257 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_node_track_caller_noprof+0x225/0x440 mm/slub.c:4283
 memdup_user+0x2b/0xc0 mm/util.c:226
 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:847 [inline]
 raw_ioctl+0xd0c/0x3cd0 drivers/usb/gadget/legacy/raw_gadget.c:1318
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl+0xf9/0x170 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5958:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:2342 [inline]
 slab_free mm/slub.c:4579 [inline]
 kfree+0x1a0/0x440 mm/slub.c:4727
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline]
 kref_put+0x4ab/0x7c0 include/linux/kref.h:65
 raw_release+0x135/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:473
 __fput+0x23f/0x880 fs/file_table.c:431
 __do_sys_close fs/open.c:1567 [inline]
 __se_sys_close fs/open.c:1552 [inline]
 __x64_sys_close+0x7f/0x110 fs/open.c:1552
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

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

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x26d9c
anon flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801ac41640 0000000000000000 dead000000000001
raw: 0000000000000000 0000000000800080 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 0xd2cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 35, tgid 35 (kworker/u8:2), ts 8792011275, free_ts 8784535053
 create_dummy_stack mm/page_owner.c:94 [inline]
 register_dummy_stack+0x8a/0xe0 mm/page_owner.c:100
 init_page_owner+0x3e/0x970 mm/page_owner.c:118
 invoke_init_callbacks mm/page_ext.c:148 [inline]
 page_ext_init+0x731/0x790 mm/page_ext.c:497
 mm_core_init+0x4c/0x60 mm/mm_init.c:2667
page last free pid 969 tgid 969 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1108 [inline]
 free_unref_page+0xcd0/0xf00 mm/page_alloc.c:2638
 vfree+0x186/0x2e0 mm/vmalloc.c:3361
 delayed_vfree_work+0x56/0x80 mm/vmalloc.c:3282
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa63/0x1850 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffff888026d9cc00: fa fb fc fc fa fb fc fc fa fb fc fc 00 00 fc fc
 ffff888026d9cc80: fa fb fc fc 00 00 fc fc fa fb fc fc 00 03 fc fc
>ffff888026d9cd00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
                   ^
 ffff888026d9cd80: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff888026d9ce00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
==================================================================

Crashes (23):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/30 10:07 upstream c1e939a21eb1 66aeb999 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: invalid-free in raw_release
2024/10/16 00:53 upstream 2f87d0916ce0 bde2d81c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/10/14 10:44 upstream 6485cf5ea253 084d8178 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/10/07 12:45 upstream 8cf0b93919e1 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/09/30 07:04 upstream e7ed34365879 ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/09/29 01:17 upstream 3efc57369a0c ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: invalid-free in raw_release
2024/09/25 00:18 upstream 97d8894b6f4c 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/09/13 11:56 upstream 196145c606d0 73e8a465 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/09/09 03:15 upstream 5dadc1be8fc5 9750182a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/09/01 09:21 upstream e8784b0aef62 1eda0d14 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/08/31 08:27 upstream 1934261d8974 1eda0d14 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/08/28 00:48 upstream 3ec3f5fc4a91 6c853ff9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/08/28 00:39 upstream 3ec3f5fc4a91 6c853ff9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/08/26 22:42 upstream 5be63fc19fca 9aee4e0b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/08/12 21:16 upstream d74da846046a 7b0f4b46 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: invalid-free in raw_release
2024/10/18 00:35 upstream 6efbea77b390 666f77ed .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/10/16 02:05 upstream 2f87d0916ce0 bde2d81c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/10/15 20:26 upstream eca631b8fe80 14943bb8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/10/12 21:17 upstream 09f6b0c8904b 084d8178 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/09/30 12:37 upstream 9852d85ec9d4 ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/09/21 23:11 upstream 88264981f208 6f888b75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/09/08 08:23 upstream d1f2d51b711a 9750182a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: invalid-free in raw_release
2024/09/29 23:10 linux-next 40e0c9d414f5 ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: invalid-free in raw_release
* Struck through repros no longer work on HEAD.