Patch "HID: core: detect and skip invalid inputs to snto32()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    HID: core: detect and skip invalid inputs to snto32()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     hid-core-detect-and-skip-invalid-inputs-to-snto32.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e6861c099f2b55e70f8714b26ed03225f7067581
Author: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Date:   Wed Dec 16 17:12:21 2020 -0800

    HID: core: detect and skip invalid inputs to snto32()
    
    [ Upstream commit a0312af1f94d13800e63a7d0a66e563582e39aec ]
    
    Prevent invalid (0, 0) inputs to hid-core's snto32() function.
    
    Maybe it is just the dummy device here that is causing this, but
    there are hundreds of calls to snto32(0, 0). Having n (bits count)
    of 0 is causing the current UBSAN trap with a shift value of
    0xffffffff (-1, or n - 1 in this function).
    
    Either of the value to shift being 0 or the bits count being 0 can be
    handled by just returning 0 to the caller, avoiding the following
    complex shift + OR operations:
    
            return value & (1 << (n - 1)) ? value | (~0U << n) : value;
    
    Fixes: dde5845a529f ("[PATCH] Generic HID layer - code split")
    Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
    Reported-by: syzbot+1e911ad71dd4ea72e04a@xxxxxxxxxxxxxxxxxxxxxxxxx
    Cc: Jiri Kosina <jikos@xxxxxxxxxx>
    Cc: Benjamin Tissoires <benjamin.tissoires@xxxxxxxxxx>
    Cc: linux-input@xxxxxxxxxxxxxxx
    Signed-off-by: Jiri Kosina <jkosina@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 263eca119ff0f..8d202011b2db5 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1300,6 +1300,9 @@ EXPORT_SYMBOL_GPL(hid_open_report);
 
 static s32 snto32(__u32 value, unsigned n)
 {
+	if (!value || !n)
+		return 0;
+
 	switch (n) {
 	case 8:  return ((__s8)value);
 	case 16: return ((__s16)value);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux