Commit d3b50414 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

HID: core: Harden s32ton() against conversion to 0 bits



[ Upstream commit a6b87bfc ]

Testing by the syzbot fuzzer showed that the HID core gets a
shift-out-of-bounds exception when it tries to convert a 32-bit
quantity to a 0-bit quantity.  Ideally this should never occur, but
there are buggy devices and some might have a report field with size
set to zero; we shouldn't reject the report or the device just because
of that.

Instead, harden the s32ton() routine so that it returns a reasonable
result instead of crashing when it is called with the number of bits
set to 0 -- the same as what snto32() does.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Reported-by: default avatar <syzbot+b63d677d63bcac06cf90@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/linux-usb/68753a08.050a0220.33d347.0008.GAE@google.com/


Tested-by: default avatar <syzbot+b63d677d63bcac06cf90@syzkaller.appspotmail.com>
Fixes: dde5845a ("[PATCH] Generic HID layer - code split")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/613a66cd-4309-4bce-a4f7-2905f9bce0c9@rowland.harvard.edu


Signed-off-by: default avatarBenjamin Tissoires <bentiss@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent d6cfa97a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment