mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3)
@ 2026-10-10  5:23 syzbot
  2026-10-10 13:48 ` Alan Stern
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2026-10-10  5:23 UTC (permalink / raw)
  To: linux-input, linux-kernel, linux-usb, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    5926a7da8789 Merge 7.3-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=11fc7ff5580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7f0127eb11110629
dashboard link: https://syzkaller.appspot.com/bug?extid=25a1d2907885b2182275
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=124fc715580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=174ed835580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0667b4f9388e/disk-5926a7da.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/0a1f8551bcab/vmlinux-5926a7da.xz
kernel image: https://storage.googleapis.com/syzbot-assets/03e51d6db4ed/bzImage-5926a7da.xz

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

usb 4-1: config 0 interface 0 has no altsetting 0
usb 4-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
usb 4-1: config 0 descriptor??
------------[ cut here ]------------
UBSAN: shift-out-of-bounds in drivers/hid/hid-core.c:80:21
shift exponent 32 is too large for 32-bit type 'int'
CPU: 1 UID: 0 PID: 780 Comm: kworker/1:2 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2026
Workqueue: usb_hub_wq hub_event
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
 ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
 __ubsan_handle_shift_out_of_bounds+0x279/0x2a0 lib/ubsan.c:494
 s32ton.part.0.cold+0x1b/0x26 drivers/hid/hid-core.c:80
 s32ton drivers/hid/hid-core.c:71 [inline]
 hid_output_field drivers/hid/hid-core.c:1871 [inline]
 hid_output_report+0x3c2/0x500 drivers/hid/hid-core.c:1904
 __usbhid_submit_report+0x33f/0xeb0 drivers/hid/usbhid/hid-core.c:595
 usbhid_submit_report drivers/hid/usbhid/hid-core.c:640 [inline]
 usbhid_request+0x7d/0xf0 drivers/hid/usbhid/hid-core.c:1303
 hid_hw_request+0x75/0xc0 drivers/hid/hid-core.c:2531
 dr_input_configured+0x62c/0x770 drivers/hid/hid-dr.c:124
 hidinput_connect+0xf59/0x2ca0 drivers/hid/hid-input.c:2414
 hid_connect+0x1330/0x1790 drivers/hid/hid-core.c:2323
 hid_hw_start+0xaa/0x140 drivers/hid/hid-core.c:2436
 __hid_device_probe drivers/hid/hid-core.c:2843 [inline]
 hid_device_probe+0x703/0x850 drivers/hid/hid-core.c:2878
 call_driver_probe drivers/base/dd.c:628 [inline]
 really_probe+0x241/0xa60 drivers/base/dd.c:706
 __driver_probe_device+0x210/0x460 drivers/base/dd.c:868
 driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
 __device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
 bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
 __device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
 device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
 bus_probe_device+0x64/0x160 drivers/base/bus.c:620
 device_add+0x121d/0x1970 drivers/base/core.c:3776
 hid_add_device+0x2bf/0x440 drivers/hid/hid-core.c:3065
 usbhid_probe+0xa64/0x10b0 drivers/hid/usbhid/hid-core.c:1452
 usb_probe_interface+0x386/0x9b0 drivers/usb/core/driver.c:399
 call_driver_probe drivers/base/dd.c:628 [inline]
 really_probe+0x241/0xa60 drivers/base/dd.c:706
 __driver_probe_device+0x210/0x460 drivers/base/dd.c:868
 driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
 __device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
 bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
 __device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
 device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
 bus_probe_device+0x64/0x160 drivers/base/bus.c:620
 device_add+0x121d/0x1970 drivers/base/core.c:3776
 usb_set_configuration+0xd97/0x1dc0 drivers/usb/core/message.c:2274
 usb_generic_driver_probe+0xa1/0xe0 drivers/usb/core/generic.c:250
 usb_probe_device+0xef/0x400 drivers/usb/core/driver.c:293
 call_driver_probe drivers/base/dd.c:628 [inline]
 really_probe+0x241/0xa60 drivers/base/dd.c:706
 __driver_probe_device+0x210/0x460 drivers/base/dd.c:868
 driver_probe_device+0x4a/0x140 drivers/base/dd.c:898
 __device_attach_driver+0x1df/0x320 drivers/base/dd.c:1026
 bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:500
 __device_attach+0x1e4/0x4d0 drivers/base/dd.c:1098
 device_initial_probe+0xaf/0xd0 drivers/base/dd.c:1153
 bus_probe_device+0x64/0x160 drivers/base/bus.c:620
 device_add+0x121d/0x1970 drivers/base/core.c:3776
 usb_new_device.part.0+0xcc2/0x1686 drivers/usb/core/hub.c:2713
 usb_new_device drivers/usb/core/hub.c:5838 [inline]
 hub_port_connect drivers/usb/core/hub.c:5585 [inline]
 hub_port_connect_change drivers/usb/core/hub.c:5725 [inline]
 port_event drivers/usb/core/hub.c:5889 [inline]
 hub_event.cold+0x51a/0xe9d drivers/usb/core/hub.c:5971
 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3396
 process_scheduled_works kernel/workqueue.c:3479 [inline]
 worker_thread+0x5ef/0xe50 kernel/workqueue.c:3560
 kthread+0x373/0x450 kernel/kthread.c:436
 ret_from_fork+0x69f/0xc90 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>
---[ end trace ]---


---
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 syzkaller@googlegroups.com.

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

If the report is already addressed, 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 report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3)
  2026-10-10  5:23 [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3) syzbot
@ 2026-10-10 13:48 ` Alan Stern
  2026-10-10 14:18   ` syzbot
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Stern @ 2026-10-10 13:48 UTC (permalink / raw)
  To: syzbot; +Cc: linux-input, linux-kernel, linux-usb, syzkaller-bugs

On Fri, Oct 09, 2026 at 10:23:36PM -0700, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    5926a7da8789 Merge 7.3-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=11fc7ff5580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=7f0127eb11110629
> dashboard link: https://syzkaller.appspot.com/bug?extid=25a1d2907885b2182275
> compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=124fc715580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=174ed835580000
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/0667b4f9388e/disk-5926a7da.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/0a1f8551bcab/vmlinux-5926a7da.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/03e51d6db4ed/bzImage-5926a7da.xz
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+25a1d2907885b2182275@syzkaller.appspotmail.com
> 
> usb 4-1: config 0 interface 0 has no altsetting 0
> usb 4-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
> usb 4-1: config 0 descriptor??
> ------------[ cut here ]------------
> UBSAN: shift-out-of-bounds in drivers/hid/hid-core.c:80:21
> shift exponent 32 is too large for 32-bit type 'int'
> CPU: 1 UID: 0 PID: 780 Comm: kworker/1:2 Not tainted syzkaller #0 PREEMPT(lazy) 
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/16/2026
> Workqueue: usb_hub_wq hub_event
> Call Trace:
>  <TASK>
>  __dump_stack lib/dump_stack.c:94 [inline]
>  dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
>  ubsan_epilogue+0xa/0x30 lib/ubsan.c:233
>  __ubsan_handle_shift_out_of_bounds+0x279/0x2a0 lib/ubsan.c:494
>  s32ton.part.0.cold+0x1b/0x26 drivers/hid/hid-core.c:80
>  s32ton drivers/hid/hid-core.c:71 [inline]

Converting a signed 32-bit integer to a signed 32-bit integer should be 
a no-op.

Alan Stern

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git 5926a7da8789

Index: usb-devel/drivers/hid/hid-core.c
===================================================================
--- usb-devel.orig/drivers/hid/hid-core.c
+++ usb-devel/drivers/hid/hid-core.c
@@ -71,8 +71,8 @@ static u32 s32ton(__s32 value, unsigned
 	if (!value || !n)
 		return 0;
 
-	if (n > 32)
-		n = 32;
+	if (n >= 32)
+		return (u32) value;
 
 	a = value >> (n - 1);
 	if (a && a != -1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3)
  2026-10-10 13:48 ` Alan Stern
@ 2026-10-10 14:18   ` syzbot
  0 siblings, 0 replies; 3+ messages in thread
From: syzbot @ 2026-10-10 14:18 UTC (permalink / raw)
  To: linux-input, linux-kernel, linux-usb, stern, syzkaller-bugs

Hello,

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

Reported-by: syzbot+25a1d2907885b2182275@syzkaller.appspotmail.com
Tested-by: syzbot+25a1d2907885b2182275@syzkaller.appspotmail.com

Tested on:

commit:         5926a7da Merge 7.3-rc6 into usb-next
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1622867f980000
kernel config:  https://syzkaller.appspot.com/x/.config?x=7f0127eb11110629
dashboard link: https://syzkaller.appspot.com/bug?extid=25a1d2907885b2182275
compiler:       gcc (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44
patch:          https://syzkaller.appspot.com/x/patch.diff?x=12bd123e580000

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-10 14:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10  5:23 [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3) syzbot
2026-10-10 13:48 ` Alan Stern
2026-10-10 14:18   ` syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®