[syzbot] [media?] [usb?] UBSAN: shift-out-of-bounds in set_flicker

41 views
Skip to first unread message

syzbot

unread,
Aug 17, 2023, 12:57:55 PM8/17/23
to hver...@xs4all.nl, linux-...@vger.kernel.org, linux...@vger.kernel.org, linu...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 55c3e571d2a0 USB: gadget: f_mass_storage: Fix unused varia..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=13eead53a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=f7789f2bd4d1e7af
dashboard link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15dfaeada80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5ac7d16ee63e/disk-55c3e571.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/ea99a7a9832f/vmlinux-55c3e571.xz
kernel image: https://storage.googleapis.com/syzbot-assets/6848258d554d/bzImage-55c3e571.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+e27f3d...@syzkaller.appspotmail.com

gspca_cpia1: usb_control_msg 03, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg 05, error -71
gspca_cpia1: usb_control_msg 03, error -71
================================================================================
UBSAN: shift-out-of-bounds in drivers/media/usb/gspca/cpia1.c:1031:27
shift exponent 245 is too large for 32-bit type 'int'
CPU: 1 PID: 25 Comm: kworker/1:1 Not tainted 6.5.0-rc4-syzkaller-00118-g55c3e571d2a0 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
ubsan_epilogue lib/ubsan.c:217 [inline]
__ubsan_handle_shift_out_of_bounds+0x27a/0x600 lib/ubsan.c:387
set_flicker.cold+0x1b/0x20 drivers/media/usb/gspca/cpia1.c:1031
sd_s_ctrl+0x2c6/0xbf0 drivers/media/usb/gspca/cpia1.c:1782
__v4l2_ctrl_handler_setup+0x511/0x710 drivers/media/v4l2-core/v4l2-ctrls-core.c:2481
v4l2_ctrl_handler_setup drivers/media/v4l2-core/v4l2-ctrls-core.c:2498 [inline]
v4l2_ctrl_handler_setup+0x50/0xa0 drivers/media/v4l2-core/v4l2-ctrls-core.c:2490
gspca_set_default_mode drivers/media/usb/gspca/gspca.c:908 [inline]
gspca_dev_probe2+0xdd6/0x1b20 drivers/media/usb/gspca/gspca.c:1541
gspca_dev_probe+0x18b/0x270 drivers/media/usb/gspca/gspca.c:1610
usb_probe_interface+0x307/0x930 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:579 [inline]
really_probe+0x234/0xc90 drivers/base/dd.c:658
__driver_probe_device+0x1de/0x4b0 drivers/base/dd.c:798
driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:828
__device_attach_driver+0x1d4/0x300 drivers/base/dd.c:956
bus_for_each_drv+0x157/0x1d0 drivers/base/bus.c:457
__device_attach+0x1e8/0x4b0 drivers/base/dd.c:1028
bus_probe_device+0x17c/0x1c0 drivers/base/bus.c:532
device_add+0x11f1/0x1b40 drivers/base/core.c:3625
usb_set_configuration+0x10cb/0x1c40 drivers/usb/core/message.c:2207
usb_generic_driver_probe+0xca/0x130 drivers/usb/core/generic.c:238
usb_probe_device+0xda/0x2c0 drivers/usb/core/driver.c:293
call_driver_probe drivers/base/dd.c:579 [inline]
really_probe+0x234/0xc90 drivers/base/dd.c:658
__driver_probe_device+0x1de/0x4b0 drivers/base/dd.c:798
driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:828
__device_attach_driver+0x1d4/0x300 drivers/base/dd.c:956
bus_for_each_drv+0x157/0x1d0 drivers/base/bus.c:457
__device_attach+0x1e8/0x4b0 drivers/base/dd.c:1028
bus_probe_device+0x17c/0x1c0 drivers/base/bus.c:532
device_add+0x11f1/0x1b40 drivers/base/core.c:3625
usb_new_device+0xd80/0x1960 drivers/usb/core/hub.c:2589
hub_port_connect drivers/usb/core/hub.c:5440 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5580 [inline]
port_event drivers/usb/core/hub.c:5740 [inline]
hub_event+0x2e62/0x4f30 drivers/usb/core/hub.c:5822
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2597
process_scheduled_works kernel/workqueue.c:2664 [inline]
worker_thread+0x896/0x1110 kernel/workqueue.c:2750
kthread+0x33a/0x430 kernel/kthread.c:389
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
</TASK>
================================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Aug 18, 2023, 10:42:33 AM8/18/23
to cool...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e27f3d...@syzkaller.appspotmail.com

Tested on:

commit: bbb9e06d Merge 6.5-rc6 into usb-next
console output: https://syzkaller.appspot.com/x/log.txt?x=17e0ddf7a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=12ca74309a170dc3
dashboard link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12b162e3a80000

Note: testing is done by a robot and is best-effort only.

Rajeshwar Shinde

unread,
Aug 18, 2023, 10:47:08 AM8/18/23
to syzbot+e27f3d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
0002-UBSAN-shift-out-of-bounds-in-set_flicker.patch

Rajeshwar Shinde

unread,
Aug 18, 2023, 1:47:23 PM8/18/23
to syzbot+e27f3d...@syzkaller.appspotmail.com, syzkall...@googlegroups.com
0001-UBSAN-shift-out-of-bounds-in-set_flicker.patch

syzbot

unread,
Aug 18, 2023, 2:50:36 PM8/18/23
to cool...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+e27f3d...@syzkaller.appspotmail.com

Tested on:

commit: bbb9e06d Merge 6.5-rc6 into usb-next
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
console output: https://syzkaller.appspot.com/x/log.txt?x=17c173f7a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=12ca74309a170dc3
dashboard link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=134dda07a80000

syzbot

unread,
Aug 27, 2023, 12:37:27 PM8/27/23
to cool...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: stack-out-of-bounds Read in set_flicker

gspca_cpia1: usb_control_msg 03, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg a1, error -32
gspca_cpia1: usb_control_msg 03, error -71
gspca_cpia1: usb_control_msg 03, error -71
==================================================================
BUG: KASAN: stack-out-of-bounds in find_last_bit include/linux/find.h:382 [inline]
BUG: KASAN: stack-out-of-bounds in set_flicker+0x101c/0x1190 drivers/media/usb/gspca/cpia1.c:1033
Read of size 8 at addr ffffc900001b6f78 by task kworker/1:1/25

CPU: 1 PID: 25 Comm: kworker/1:1 Not tainted 6.5.0-rc6-syzkaller-00158-g895ed7eb263d-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
Workqueue: usb_hub_wq hub_event
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:364 [inline]
print_report+0xc4/0x620 mm/kasan/report.c:475
kasan_report+0xda/0x110 mm/kasan/report.c:588
find_last_bit include/linux/find.h:382 [inline]
set_flicker+0x101c/0x1190 drivers/media/usb/gspca/cpia1.c:1033
sd_s_ctrl+0x2c6/0xbf0 drivers/media/usb/gspca/cpia1.c:1787
process_one_work+0xaa2/0x16f0 kernel/workqueue.c:2600
worker_thread+0x687/0x1110 kernel/workqueue.c:2751
kthread+0x33a/0x430 kernel/kthread.c:389
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
</TASK>

The buggy address belongs to stack of task kworker/1:1/25
and is located at offset 32 in frame:
set_flicker+0x0/0x1190 drivers/media/usb/gspca/cpia1.c:577

This frame has 1 object:
[32, 36) 'currentexp'

The buggy address belongs to the virtual mapping at
[ffffc900001b0000, ffffc900001b9000) created by:
kernel_clone+0xfc/0x820 kernel/fork.c:2912

The buggy address belongs to the physical page:
page:ffffea00040b97c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102e5f
flags: 0x200000000000000(node=0|zone=2)
page_type: 0xffffffff()
raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 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 0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_ZERO), pid 2, tgid 2 (kthreadd), ts 2379209355, free_ts 0
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1570
prep_new_page mm/page_alloc.c:1577 [inline]
get_page_from_freelist+0x10e1/0x2fd0 mm/page_alloc.c:3221
__alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4477
__alloc_pages_node include/linux/gfp.h:237 [inline]
alloc_pages_node include/linux/gfp.h:260 [inline]
vm_area_alloc_pages mm/vmalloc.c:3061 [inline]
__vmalloc_area_node mm/vmalloc.c:3135 [inline]
__vmalloc_node_range+0x625/0x1540 mm/vmalloc.c:3316
alloc_thread_stack_node kernel/fork.c:309 [inline]
dup_task_struct kernel/fork.c:1113 [inline]
copy_process+0x13de/0x7300 kernel/fork.c:2330
kernel_clone+0xfc/0x820 kernel/fork.c:2912
kernel_thread+0xc0/0x100 kernel/fork.c:2974
create_kthread kernel/kthread.c:412 [inline]
kthreadd+0x4fc/0x7b0 kernel/kthread.c:747
ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304
page_owner free stack trace missing

Memory state around the buggy address:
ffffc900001b6e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc900001b6e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc900001b6f00: 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04
^
ffffc900001b6f80: f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc900001b7000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


Tested on:

commit: 895ed7eb Merge tag 'usb-serial-6.6-rc1' of https://git..
console output: https://syzkaller.appspot.com/x/log.txt?x=168c5187a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=12ca74309a170dc3
dashboard link: https://syzkaller.appspot.com/bug?extid=e27f3dbdab04e43b9f73
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14c5c813a80000

Reply all
Reply to author
Forward
0 new messages