Commit 3c86548
HID: core: Harden s32ton() against conversion to 0 bits
[ Upstream commit a6b87bf ]
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: Alan Stern <[email protected]>
Reported-by: [email protected]
Closes: https://lore.kernel.org/linux-usb/[email protected]/
Tested-by: [email protected]
Fixes: dde5845 ("[PATCH] Generic HID layer - code split")
Cc: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Benjamin Tissoires <[email protected]>
[ s32ton() was moved by c653ffc ("HID: stop exporting hid_snto32()").
Minor context change fixed. ]
Signed-off-by: Wenshan Lan <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 66731f7 commit 3c86548
1 file changed
+6
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
1357 | | - | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
1358 | 1363 | | |
1359 | 1364 | | |
1360 | 1365 | | |
| |||
0 commit comments