svn commit: r235301 - head/sys/kern

Bruce Evans brde at optusnet.com.au
Sat May 12 07:38:04 UTC 2012


On Fri, 11 May 2012, Xin LI wrote:

>> Log:
>>  Revert previous revision, misunderstood the code :(
>>
>> Modified:
>>  head/sys/kern/kern_kthread.c
>>
>> Modified: head/sys/kern/kern_kthread.c
>> ==============================================================================
>> --- head/sys/kern/kern_kthread.c        Fri May 11 23:41:52 2012        (r235300)
>> +++ head/sys/kern/kern_kthread.c        Fri May 11 23:43:32 2012        (r235301)
>> @@ -182,7 +182,6 @@ kproc_suspend(struct proc *p, int timo)
>>                return (EINVAL);
>>        }
>>        SIGADDSET(p->p_siglist, SIGSTOP);
>> -       PROC_UNLOCK(p);
>>        wakeup(p);
>>        return msleep(&p->p_siglist, &p->p_mtx, PPAUSE | PDROP, "suspkp", timo);

Please don't use mailer clients that corrupt whitespace to binary characters.
The above is unreadable in vi (but i remember it from the original).

> For the record, p->p_mtx is the mutex used by PROC_[UN]LOCK(), which
> has to be held while calling msleep().

Even if it weren't, dropping the lock before sleeping would give a classic
race.

Otherwise, PROC_UNLOCK() is a good obfuscation.  p_mtx in the sleep call
isn't similarly obfuscated.  Some subsystems have a macro that obfuscates
the name of their lock(s) too, but proc.h doesn't.  kern/*.c has 23
hard-coded references of the form &somep->p_mtx.

Bruce


More information about the svn-src-all mailing list