Skip to contentSkip to conversation

HID: hiddev: potential info leak in hiddev_ioctl()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 23, 2011 – Sep 26, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hiddev: potential info leak in hiddev_ioctl()

Smatch has a new check for Rosenberg type information leaks where structs are copied to the user with uninitialized stack data in them.

In this case, the hiddev_devinfo struct has a two byte hole.

struct hiddev_devinfo {

        __u32                      bustype;              /*     0     4 */
        __u32                      busnum;               /*     4     4 */
        __u32                      devnum;               /*     8     4 */
        __u32                      ifnum;                /*    12     4 */
        __s16                      vendor;               /*    16     2 */
        __s16                      product;              /*    18     2 */
        __s16                      version;              /*    20     2 */

/* XXX 2 bytes hole, try to pack */

__u32 num_applications; /* 24 4 */

drivers/hid/usbhid/hiddev.c +2 -0
index 7c1188b..4ef02b2 100644
@@ -641,6 +641,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			struct usb_device *dev = hid_to_usb_dev(hid);
 			struct usbhid_device *usbhid = hid->driver_data;
 
+			memset(&dinfo, 0, sizeof(dinfo));
+
 			dinfo.bustype = BUS_USB;
 			dinfo.busnum = dev->bus->busnum;
 			dinfo.devnum = dev->devnum;
Applied
#1 lore raw
Quoted 25 lines · Dan Carpenter

Smatch has a new check for Rosenberg type information leaks where structs are copied to the user with uninitialized stack data in them.

In this case, the hiddev_devinfo struct has a two byte hole.

struct hiddev_devinfo {

        __u32                      bustype;              /*     0     4 */
        __u32                      busnum;               /*     4     4 */
        __u32                      devnum;               /*     8     4 */
        __u32                      ifnum;                /*    12     4 */
        __s16                      vendor;               /*    16     2 */
        __s16                      product;              /*    18     2 */
        __s16                      version;              /*    20     2 */

/* XXX 2 bytes hole, try to pack */

__u32 num_applications; /* 24 4 */

drivers/hid/usbhid/hiddev.c +0 -0
index 7c1188b..4ef02b2 100644

drivers/hid/usbhid/hiddev.c static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 648

Quoted 8 lines
drivers/hid/usbhid/hiddev.c +2 -0
@@ -641,6 +641,8 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 			struct usb_device *dev = hid_to_usb_dev(hid);
 			struct usbhid_device *usbhid = hid->driver_data;
 
+			memset(&dinfo, 0, sizeof(dinfo));
+
 			dinfo.bustype = BUS_USB;
 			dinfo.busnum = dev->bus->busnum;
 			dinfo.devnum = dev->devnum;

Applied, thanks Dan.

Signature · 2 lines
Jiri Kosina
SUSE Labs