cvs commit: src/sys/kern tty.c

Martin Blapp mb at imp.ch
Wed Dec 20 03:14:56 PST 2006


Hi,

> Since proctree_lock is a sx lock which uses 2 condition variables,
> they alredy drop Giant (DROP_GIANT()) before sleeping. Are you secure
> it is the right thing to do here?

Yes I am.

sx_slock() can call cv_wait() which later can call cv_wait_unlock ...
if there is already a lock we need to share ... After a possible
sleep cv_wait_unlock looks like:

cv_wait_unlock(struct cv *cvp, struct mtx *mp)

[...]
         sleepq_lock(cvp);

         cvp->cv_waiters++;
         DROP_GIANT();
         mtx_unlock(mp);

[...]

It can call DROP_GIANT for a short amount of time. This was the race.

I already fixed it (but haven't seen the real cause for the crashes) once in 
STABLE and HEAD, but backed it out again because I (and jhb) were sure that the 
tty driver was protected fully by the GIANT lock after I fixed severall 
possible race places in kern_proc.c. I had no idea that sx_slock()  and sx_slock 
both can drop GIANT for a short time and that we need carefully recheck 
variables.

Martin


More information about the cvs-src mailing list