Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: slab-out-of-bounds Read in mon_bin_flush
==================================================================
BUG: KASAN: slab-out-of-bounds in MON_OFF2HDR drivers/usb/mon/mon_bin.c:207 [inline]
BUG: KASAN: slab-out-of-bounds in mon_bin_flush+0x121/0x260 drivers/usb/mon/mon_bin.c:884
Read of size 8 at addr ffff8881134c7ab8 by task syz-executor.0/454
CPU: 1 PID: 454 Comm: syz-executor.0 Not tainted 6.0.0-rc5-syzkaller-00094-ga335366bad13 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
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:317 [inline]
print_report+0x173/0x630 mm/kasan/report.c:433
kasan_report+0xe6/0x110 mm/kasan/report.c:495
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:307
MON_OFF2HDR drivers/usb/mon/mon_bin.c:207 [inline]
mon_bin_flush+0x121/0x260 drivers/usb/mon/mon_bin.c:884
mon_bin_ioctl+0x2fb/0xed0 drivers/usb/mon/mon_bin.c:1060
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0x115/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+0x2f/0x50 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f4674489409
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f46756cb168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f467459bf80 RCX: 00007f4674489409
RDX: 0000000000000006 RSI: 0000000000009208 RDI: 0000000000000003
RBP: 00007f46744e4367 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd92894c7f R14: 00007f46756cb300 R15: 0000000000022000
</TASK>
Allocated by task 175:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:45 [inline]
set_alloc_info mm/kasan/common.c:437 [inline]
____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:516
__kasan_kmalloc+0x9/0x10 mm/kasan/common.c:525
kasan_kmalloc include/linux/kasan.h:234 [inline]
kmem_cache_alloc_trace+0x1f0/0x320 mm/slub.c:3284
kmalloc include/linux/slab.h:600 [inline]
kzalloc include/linux/slab.h:733 [inline]
kobject_uevent_env+0x265/0x730 lib/kobject_uevent.c:524
kobject_synth_uevent+0x3c4/0x930 lib/kobject_uevent.c:208
uevent_store+0x25/0x60 drivers/base/core.c:2509
dev_attr_store+0x5c/0x80 drivers/base/core.c:2211
sysfs_kf_write+0x123/0x140 fs/sysfs/file.c:136
kernfs_fop_write_iter+0x2cd/0x410 fs/kernfs/file.c:354
call_write_iter include/linux/fs.h:2187 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8b5/0xef0 fs/read_write.c:578
ksys_write+0x198/0x2c0 fs/read_write.c:631
__do_sys_write fs/read_write.c:643 [inline]
__se_sys_write fs/read_write.c:640 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:640
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
Freed by task 175:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x70 mm/kasan/common.c:45
kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
____kasan_slab_free+0x137/0x180 mm/kasan/common.c:367
__kasan_slab_free+0x11/0x20 mm/kasan/common.c:375
kasan_slab_free include/linux/kasan.h:200 [inline]
slab_free_hook mm/slub.c:1754 [inline]
slab_free_freelist_hook+0xc9/0x1a0 mm/slub.c:1780
slab_free mm/slub.c:3534 [inline]
kfree+0xcf/0x1f0 mm/slub.c:4562
kobject_uevent_env+0x51c/0x730 lib/kobject_uevent.c:626
kobject_synth_uevent+0x3c4/0x930 lib/kobject_uevent.c:208
uevent_store+0x25/0x60 drivers/base/core.c:2509
dev_attr_store+0x5c/0x80 drivers/base/core.c:2211
sysfs_kf_write+0x123/0x140 fs/sysfs/file.c:136
kernfs_fop_write_iter+0x2cd/0x410 fs/kernfs/file.c:354
call_write_iter include/linux/fs.h:2187 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8b5/0xef0 fs/read_write.c:578
ksys_write+0x198/0x2c0 fs/read_write.c:631
__do_sys_write fs/read_write.c:643 [inline]
__se_sys_write fs/read_write.c:640 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:640
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
The buggy address belongs to the object at ffff8881134c6000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 2744 bytes to the right of
4096-byte region [ffff8881134c6000, ffff8881134c7000)
The buggy address belongs to the physical page:
page:ffffea00044d3000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1134c0
head:ffffea00044d3000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head|zone=2)
raw: 8000000000010200 0000000000000000 dead000000000122 ffff888100042140
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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 175, tgid 175 (udevadm), ts 3562996396, free_ts 0
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x15b/0x160 mm/page_alloc.c:2525
prep_new_page mm/page_alloc.c:2532 [inline]
get_page_from_freelist+0x412/0x8e0 mm/page_alloc.c:4283
__alloc_pages+0x3d1/0x7c0 mm/page_alloc.c:5515
allocate_slab+0x69/0x480 mm/slub.c:1969
new_slab mm/slub.c:2029 [inline]
___slab_alloc+0x2c2/0x6a0 mm/slub.c:3031
__slab_alloc+0x4a/0x90 mm/slub.c:3118
slab_alloc_node mm/slub.c:3209 [inline]
slab_alloc mm/slub.c:3251 [inline]
kmem_cache_alloc_trace+0x221/0x320 mm/slub.c:3282
kmalloc include/linux/slab.h:600 [inline]
kzalloc include/linux/slab.h:733 [inline]
kobject_uevent_env+0x265/0x730 lib/kobject_uevent.c:524
kobject_synth_uevent+0x3c4/0x930 lib/kobject_uevent.c:208
uevent_store+0x25/0x60 drivers/base/core.c:2509
dev_attr_store+0x5c/0x80 drivers/base/core.c:2211
sysfs_kf_write+0x123/0x140 fs/sysfs/file.c:136
kernfs_fop_write_iter+0x2cd/0x410 fs/kernfs/file.c:354
call_write_iter include/linux/fs.h:2187 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x8b5/0xef0 fs/read_write.c:578
ksys_write+0x198/0x2c0 fs/read_write.c:631
__do_sys_write fs/read_write.c:643 [inline]
__se_sys_write fs/read_write.c:640 [inline]
__x64_sys_write+0x7b/0x90 fs/read_write.c:640
page_owner free stack trace missing
Memory state around the buggy address:
ffff8881134c7980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881134c7a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8881134c7a80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
^
ffff8881134c7b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8881134c7b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
general protection fault, probably for non-canonical address 0xdffffc000000013c: 0000 [#1] PREEMPT SMP KASAN
KASAN: null-ptr-deref in range [0x00000000000009e0-0x00000000000009e7]
CPU: 1 PID: 454 Comm: syz-executor.0 Tainted: G B 6.0.0-rc5-syzkaller-00094-ga335366bad13 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
RIP: 0010:mon_bin_flush+0x141/0x260 drivers/usb/mon/mon_bin.c:885
Code: 74 08 48 89 df e8 1f 1b 8d fe 48 8b 03 41 81 e7 ff 0f 00 00 4d 8d 7c 07 24 4c 89 f8 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df <0f> b6 04 18 84 c0 75 6b 41 8b 37 83 c6 40 4c 89 f7 e8 a9 fd ff ff
RSP: 0018:ffffc90002edfd08 EFLAGS: 00010007
RAX: 000000000000013c RBX: dffffc0000000000 RCX: ffff88810d33a200
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90002edfd70 R08: ffffffff8144ac33 R09: fffffbfff0d492f1
R10: fffffbfff0d492f1 R11: 1ffffffff0d492f0 R12: 00000000fffffffd
R13: ffff888112418b18 R14: ffff888112418b00 R15: 00000000000009e4
FS: 00007f46756cb700(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f46744d7e58 CR3: 0000000124e88000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
mon_bin_ioctl+0x2fb/0xed0 drivers/usb/mon/mon_bin.c:1060
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0x115/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+0x2f/0x50 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f4674489409
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f46756cb168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f467459bf80 RCX: 00007f4674489409
RDX: 0000000000000006 RSI: 0000000000009208 RDI: 0000000000000003
RBP: 00007f46744e4367 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd92894c7f R14: 00007f46756cb300 R15: 0000000000022000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:mon_bin_flush+0x141/0x260 drivers/usb/mon/mon_bin.c:885
Code: 74 08 48 89 df e8 1f 1b 8d fe 48 8b 03 41 81 e7 ff 0f 00 00 4d 8d 7c 07 24 4c 89 f8 48 c1 e8 03 48 bb 00 00 00 00 00 fc ff df <0f> b6 04 18 84 c0 75 6b 41 8b 37 83 c6 40 4c 89 f7 e8 a9 fd ff ff
RSP: 0018:ffffc90002edfd08 EFLAGS: 00010007
RAX: 000000000000013c RBX: dffffc0000000000 RCX: ffff88810d33a200
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90002edfd70 R08: ffffffff8144ac33 R09: fffffbfff0d492f1
R10: fffffbfff0d492f1 R11: 1ffffffff0d492f0 R12: 00000000fffffffd
R13: ffff888112418b18 R14: ffff888112418b00 R15: 00000000000009e4
FS: 00007f46756cb700(0000) GS:ffff8881f7300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f46744d7e58 CR3: 0000000124e88000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 74 08 je 0xa
2: 48 89 df mov %rbx,%rdi
5: e8 1f 1b 8d fe callq 0xfe8d1b29
a: 48 8b 03 mov (%rbx),%rax
d: 41 81 e7 ff 0f 00 00 and $0xfff,%r15d
14: 4d 8d 7c 07 24 lea 0x24(%r15,%rax,1),%r15
19: 4c 89 f8 mov %r15,%rax
1c: 48 c1 e8 03 shr $0x3,%rax
20: 48 bb 00 00 00 00 00 movabs $0xdffffc0000000000,%rbx
27: fc ff df
* 2a: 0f b6 04 18 movzbl (%rax,%rbx,1),%eax <-- trapping instruction
2e: 84 c0 test %al,%al
30: 75 6b jne 0x9d
32: 41 8b 37 mov (%r15),%esi
35: 83 c6 40 add $0x40,%esi
38: 4c 89 f7 mov %r14,%rdi
3b: e8 a9 fd ff ff callq 0xfffffde9
Tested on:
commit: a335366b Merge tag 'gpio-fixes-for-v6.0-rc6' of git://..
console output:
https://syzkaller.appspot.com/x/log.txt?x=1488f1d8880000
kernel config:
https://syzkaller.appspot.com/x/.config?x=a3858b37a617f2bb
dashboard link:
https://syzkaller.appspot.com/bug?extid=23f57c5ae902429285d7