Re: [syzbot] [input?] [usb?] UBSAN: shift-out-of-bounds in s32ton (3)

From: Alan Stern

Date: Sat Oct 10 2026 - 09:52:03 EST


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@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> 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)