* [patch] hiddev: fix incorrect hiddev freeing
@ 2009-03-09 2:31 Johannes Weiner
2009-03-09 2:38 ` Johannes Weiner
2009-03-09 22:37 ` Johannes Weiner
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Weiner @ 2009-03-09 2:31 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Oliver Neukum, linux-kernel, stable
When hiddev_open() fails for whatever reason, free the just allocated
hiddev_list structure shared hiddev potentially still in use.
The hiddev is freed in device disconnect/last close of the device file
and must not be freed while there are possibly existing references to
it.
This is probably responsible for these
http://kerneloops.org/oops.php?number=221185
http://kerneloops.org/oops.php?number=220365
where a reader sleeps on the waitqueue, the device gets disconnected
(exist -> 0) another user tries to open it, fails on the exist check
and frees the hiddev from the table. The finish_wait() in the reader
will then dereference the hiddev to get to the waitqueue and oopses.
This was introduced by commit 079034073faf974973baa0256b029451f6e768ad
"HID: hiddev cleanup -- handle all error conditions properly".
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Oliver Neukum <oliver@neukum.name>
---
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 4940e4d..00ea1ed 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -306,7 +306,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
return 0;
bail:
file->private_data = NULL;
- kfree(list->hiddev);
+ kfree(list);
return res;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [patch] hiddev: fix incorrect hiddev freeing
2009-03-09 2:31 [patch] hiddev: fix incorrect hiddev freeing Johannes Weiner
@ 2009-03-09 2:38 ` Johannes Weiner
2009-03-09 22:37 ` Johannes Weiner
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2009-03-09 2:38 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Oliver Neukum, linux-kernel, stable
On Mon, Mar 09, 2009 at 03:31:51AM +0100, Johannes Weiner wrote:
> When hiddev_open() fails for whatever reason, free the just allocated
> hiddev_list structure shared hiddev potentially still in use.
^
instead of
Sorry, it's late (or early?) Need a resend?
> The hiddev is freed in device disconnect/last close of the device file
> and must not be freed while there are possibly existing references to
> it.
>
> This is probably responsible for these
>
> http://kerneloops.org/oops.php?number=221185
> http://kerneloops.org/oops.php?number=220365
>
> where a reader sleeps on the waitqueue, the device gets disconnected
> (exist -> 0) another user tries to open it, fails on the exist check
> and frees the hiddev from the table. The finish_wait() in the reader
> will then dereference the hiddev to get to the waitqueue and oopses.
>
> This was introduced by commit 079034073faf974973baa0256b029451f6e768ad
> "HID: hiddev cleanup -- handle all error conditions properly".
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Oliver Neukum <oliver@neukum.name>
> ---
>
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index 4940e4d..00ea1ed 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -306,7 +306,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
> return 0;
> bail:
> file->private_data = NULL;
> - kfree(list->hiddev);
> + kfree(list);
> return res;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch] hiddev: fix incorrect hiddev freeing
2009-03-09 2:31 [patch] hiddev: fix incorrect hiddev freeing Johannes Weiner
2009-03-09 2:38 ` Johannes Weiner
@ 2009-03-09 22:37 ` Johannes Weiner
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2009-03-09 22:37 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Oliver Neukum, linux-kernel, stable
On Mon, Mar 09, 2009 at 03:31:51AM +0100, Johannes Weiner wrote:
> When hiddev_open() fails for whatever reason, free the just allocated
> hiddev_list structure shared hiddev potentially still in use.
>
> The hiddev is freed in device disconnect/last close of the device file
> and must not be freed while there are possibly existing references to
> it.
>
> This is probably responsible for these
>
> http://kerneloops.org/oops.php?number=221185
> http://kerneloops.org/oops.php?number=220365
>
> where a reader sleeps on the waitqueue, the device gets disconnected
> (exist -> 0) another user tries to open it, fails on the exist check
> and frees the hiddev from the table. The finish_wait() in the reader
> will then dereference the hiddev to get to the waitqueue and oopses.
>
> This was introduced by commit 079034073faf974973baa0256b029451f6e768ad
> "HID: hiddev cleanup -- handle all error conditions properly".
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Oliver Neukum <oliver@neukum.name>
> ---
>
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index 4940e4d..00ea1ed 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -306,7 +306,7 @@ static int hiddev_open(struct inode *inode, struct file *file)
> return 0;
> bail:
> file->private_data = NULL;
> - kfree(list->hiddev);
> + kfree(list);
> return res;
This isn't responsible for the above quoted oopsen but I think I found
the real issue. Resend coming soon.
Dear stable team, I mixed up the commit date with the authoring date.
The bugs were introduced after .28, so there is no need to backport
anything unless my fixes fail to get into .29. So please ignore for
now.
Hannes
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-09 22:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-09 2:31 [patch] hiddev: fix incorrect hiddev freeing Johannes Weiner
2009-03-09 2:38 ` Johannes Weiner
2009-03-09 22:37 ` Johannes Weiner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox