public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix usb skeleton driver
@ 2012-06-06 16:27 stefani
  2012-06-06 16:27 ` [PATCH 01/11] fix wrong label in skel_open stefani
                   ` (11 more replies)
  0 siblings, 12 replies; 36+ messages in thread
From: stefani @ 2012-06-06 16:27 UTC (permalink / raw)
  To: linux-kernel, gregkh, oneukum; +Cc: alan, linux-usb, Stefani Seibold

From: Stefani Seibold <stefani@seibold.net>

This is a fix for the USB skeleton driver to bring it in shape.

- The usb_interface structure pointer will be no longer stored 
- Every access to the USB will be handled trought the usb_interface pointer
- Add a new bool 'connected' for signaling a disconnect (== false)
- Handle a non blocking read without blocking
- Code cleanup
- Synchronize disconnect() handler with open() and release(), to fix races
- Introduced fsync
- Single user mode
- Eliminated dead code
- Save some bytes in the dev structure

Some word about the open()/release() races with disconnect() of an USB device
(which can happen any time):
- The return interface pointer from usb_find_interface() could be already owned
  by an other driver and no more longer handle by the skeleton driver.
- Or the dev pointer return by usb_get_intfdata() could point to an already
  release memory.

This races can not handled by a per device mutex. Only a driver global mutex
could do this job, since the kref_put() in the skel_disconnect() must be
protected, otherwise skel_open() could access an already released memory.

I know that this races are very small, but on heavy load or misdesigned or buggy
hardware this could lead in a OOPS or unpredictable behavior.

The patch is against linux 3.5.0 commit eea5b5510fc5545d15b69da8e485a7424ae388cf

Hope this helps

Signed-off-by: Stefani Seibold <stefani@seibold.net>

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2012-06-08 13:46 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-06 16:27 [PATCH] fix usb skeleton driver stefani
2012-06-06 16:27 ` [PATCH 01/11] fix wrong label in skel_open stefani
2012-06-06 18:52   ` Oliver Neukum
2012-06-06 19:59     ` Stefani Seibold
2012-06-06 16:27 ` [PATCH 02/11] code cleanup stefani
2012-06-06 18:57   ` Oliver Neukum
2012-06-06 16:27 ` [PATCH 03/11] remove dead code stefani
2012-06-06 16:27 ` [PATCH 04/11] remove usb_interface pointer stefani
2012-06-06 18:59   ` Oliver Neukum
2012-06-06 20:04     ` Stefani Seibold
2012-06-06 20:19       ` Alan Stern
2012-06-06 22:54   ` Greg KH
2012-06-07  8:07     ` Stefani Seibold
2012-06-07 11:51     ` Stefani Seibold
2012-06-07 14:28       ` Alan Stern
2012-06-07 15:03         ` Stefani Seibold
2012-06-07 15:27           ` Alan Stern
2012-06-07 19:50             ` Stefani Seibold
2012-06-07 20:42               ` Alan Stern
2012-06-08  7:18               ` RFC: remove usb_device pointer from usb_skeleton.c Stefani Seibold
2012-06-08  8:28                 ` Oliver Neukum
2012-06-08 13:46                 ` Alan Stern
2012-06-06 16:27 ` [PATCH 05/11] remove unneeded forward declaration stefani
2012-06-06 16:27 ` [PATCH 06/11] introduce fsync function stefani
2012-06-06 16:27 ` [PATCH 07/11] remove pr_err() noise in skel_open stefani
2012-06-06 16:27 ` [PATCH 08/11] Handle a non blocking read without blocking stefani
2012-06-06 16:27 ` [PATCH 09/11] Synchronize disconnect() handler with open() and release(), to fix races stefani
2012-06-06 16:27 ` [PATCH 10/11] Introduce single user mode stefani
2012-06-06 16:27 ` [PATCH 11/11] Bump version number and add aditional author stefani
2012-06-06 16:55 ` [PATCH] fix usb skeleton driver Alan Stern
2012-06-06 17:53   ` Stefani Seibold
2012-06-06 18:16     ` Alan Stern
2012-06-06 20:19       ` Stefani Seibold
2012-06-06 20:22         ` Alan Stern
2012-06-07  8:13           ` Stefani Seibold
2012-06-07  7:10         ` Bjørn Mork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox