Skip to contentSkip to conversation

KASAN: use-after-free Read in hiddev_release

DISCUSSION Jiri Kosina 1 participant 1 message Aug 5, 2019 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jiri Kosina

author maintainer
#1 lore raw
Quoted 22 lines · Hillf Danton

1, no dev no open.

drivers/hid/usbhid/hiddev.c +4 -1
@@ -284,6 +284,10 @@ static int hiddev_open(struct inode *ino
 	spin_unlock_irq(&list->hiddev->list_lock);
 
 	mutex_lock(&hiddev->existancelock);
+	if (!list->hiddev->exist) {
+		res = -ENODEV;
+		goto bail_unlock;
+	}
 	if (!list->hiddev->open++)
 		if (list->hiddev->exist) {
 			struct hid_device *hid = hiddev->hid;
--

2, list_del before vfree.

drivers/hid/usbhid/hiddev.c bail_normal_power: · line 312

Quoted 9 lines
drivers/hid/usbhid/hiddev.c +3 -0
@@ -300,6 +304,9 @@ bail_normal_power:
 	hid_hw_power(hid, PM_HINT_NORMAL);
 bail_unlock:
 	mutex_unlock(&hiddev->existancelock);
+	spin_lock_irq(&list->hiddev->list_lock);
+	list_del(&list->node);
+	spin_unlock_irq(&list->hiddev->list_lock);
 bail:
 	file->private_data = NULL;
 	vfree(list);

Hilf,

both patches look good to me. Could you please resend them properly so that I could apply them? Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs