* [PATCH] HID: core: Fix out-of-bounds left shift by 32 in s32ton()
@ 2026-10-10 17:44 Alan Stern
2026-10-10 17:49 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Alan Stern @ 2026-10-10 17:44 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: Greg KH, linux-input, USB mailing list, syzbot, syzkaller-bugs
Syzbot reported an out-of-bounds shift (32-bit integer shifted left by
32) in the s32ton() routine in the HID core. This routine converts a
signed 32-bit integer to a signed n-bit integer, and it caps the value
of n at 32. But when n == 32 there's no need to do anything; it can
simply return the input value. This will avoid calculating (1 << n)
when n is 32, which was the cause of the invalid shift.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Fixes: 69c02ffde6ed ("HID: core: clamp report_size in s32ton() to avoid undefined shift")
Reported-by: syzbot+25a1d2907885b2182275@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-usb/6ac9cbd8.a150a118.27e199.0025.GAE@google.com/
Tested-by: syzbot+25a1d2907885b2182275@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
---
drivers/hid/hid-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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] 2+ messages in thread
* Re: [PATCH] HID: core: Fix out-of-bounds left shift by 32 in s32ton()
2026-10-10 17:44 [PATCH] HID: core: Fix out-of-bounds left shift by 32 in s32ton() Alan Stern
@ 2026-10-10 17:49 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-10-10 17:49 UTC (permalink / raw)
To: Alan Stern; +Cc: dmitry.torokhov, linux-usb, linux-input
> Syzbot reported an out-of-bounds shift (32-bit integer shifted left by
> 32) in the s32ton() routine in the HID core. This routine converts a
> signed 32-bit integer to a signed n-bit integer, and it caps the value
> of n at 32. But when n == 32 there's no need to do anything; it can
> simply return the input value. This will avoid calculating (1 << n)
> when n is 32, which was the cause of the invalid shift.
>
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/dfa0aa1c-e55e-4316-8307-f72a07383634@rowland.harvard.edu?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-10 17:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10 17:44 [PATCH] HID: core: Fix out-of-bounds left shift by 32 in s32ton() Alan Stern
2026-10-10 17:49 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox