Re: BUG: lock held when returning to user space

From: Vegard Nossum
Date: Wed Mar 12 2008 - 12:30:09 EST


On Wed, Mar 12, 2008 at 4:45 PM, Frank Munzert
<frankm@xxxxxxxxxxxxxxxxxx> wrote:
> we provided a device driver vmur dealing with z/VM virtual unit record
> devices (reader, punch, printer). A corresponding user space tool
> provides functions similar to the CMS commands RECEIVE, PUNCH, PRINT.
> Unit record devices are not meant for concurrent read or write by
> multiple users, that's why we need to serialize access. The driver's
> open method uses mutex_trylock or mutex_lock_interruptible to ensure
> exclusive access to the device, while its release method uses
> mutex_unlock.

snip.

> For the vmur device driver it is crucial to have only one process access
> a given unit record device node at a given time. So having open hold the
> mutex and return to user space is exactly what we want. Is there any
> annotation to tell lockdep to suppress or bypass this kind of warning?

This sounds like a serious abuse of mutexes.

Wouldn't it be correct to use the mutex to protect a separate variable
(which indicates whether the device has been open()ed) and nothing
else? Then there is no need to hold the mutex across the syscalls and
open() can simply fail if the separate variable is set.


Kind regards,
Vegard Nossum
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/