lkml.org 
[lkml]   [2019]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.2 024/135] HID: holtek: test for sanity of intfdata
    Date
    From: Oliver Neukum <oneukum@suse.com>

    commit 01ec0a5f19c8c82960a07f6c7410fc9e01d7fb51 upstream.

    The ioctl handler uses the intfdata of a second interface,
    which may not be present in a broken or malicious device, hence
    the intfdata needs to be checked for NULL.

    [jkosina@suse.cz: fix newly added spurious space]
    Reported-by: syzbot+965152643a75a56737be@syzkaller.appspotmail.com
    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/hid/hid-holtek-kbd.c | 9 +++++++--
    1 file changed, 7 insertions(+), 2 deletions(-)

    diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c
    index b3d502421b79d..0a38e8e9bc783 100644
    --- a/drivers/hid/hid-holtek-kbd.c
    +++ b/drivers/hid/hid-holtek-kbd.c
    @@ -123,9 +123,14 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,

    /* Locate the boot interface, to receive the LED change events */
    struct usb_interface *boot_interface = usb_ifnum_to_if(usb_dev, 0);
    + struct hid_device *boot_hid;
    + struct hid_input *boot_hid_input;

    - struct hid_device *boot_hid = usb_get_intfdata(boot_interface);
    - struct hid_input *boot_hid_input = list_first_entry(&boot_hid->inputs,
    + if (unlikely(boot_interface == NULL))
    + return -ENODEV;
    +
    + boot_hid = usb_get_intfdata(boot_interface);
    + boot_hid_input = list_first_entry(&boot_hid->inputs,
    struct hid_input, list);

    return boot_hid_input->input->event(boot_hid_input->input, type, code,
    --
    2.20.1
    \
     
     \ /
      Last update: 2019-08-22 19:26    [W:2.404 / U:0.040 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site