panic by unlocking of mutex in KLD

Alexej Sokolov bsd.quest at googlemail.com
Mon Jan 12 10:16:53 PST 2009


2009/1/12 Mateusz Guzik <mjguzik at gmail.com>

> On Mon, Jan 12, 2009 at 05:19:56PM +0100, Alexej Sokolov wrote:
> > 2009/1/12 Mateusz Guzik <mjguzik at gmail.com>
> > > Mutexes have owners. It panics on loading because processes cannot
> > > return to userland with locks held.
> >
> > i am not sure about it. Some time ago i implemented a charecter device
> with
> > two syscalls: write, read. "write" lock the mutex and  "read" unlock it.
> The
> > user space programm opens device, then mekes "write" (mutex will held in
> > kernel), goes back to user space, then makes "read" (mutex will unlocked
> in
> > kernel) and it all run without panic. If needed i can post the source
> code.
> >
>
> Do you have kernel compiled with WITNESS? At least on -CURRENT the
> kernel panicked like this (while loading your module):
>
> System call kldload returning with 1 locks held

My kernel is compiled without WITNESS. And it allows to lock mutex in one
systcall (for example "write") and to unlock it in other ("read").
Do you mean it is "very bad idea" to do something like this ?
I could not find anywhere in the documentation that a it is not allowed to
return in the user space with a locked mutex.
Can you give me some reference on man page, source code or something other
from where can I understand it ?

Thanx a lot,
Alexej



>
>
> --
> Mateusz Guzik <mjguzik at gmail.com>
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>


More information about the freebsd-hackers mailing list