cvs commit: src/sys/netinet6 in6_src.c

John Baldwin jhb at FreeBSD.org
Tue Aug 16 20:22:55 GMT 2005


On Tuesday 16 August 2005 03:49 pm, Hajimu UMEMOTO wrote:
> ume         2005-08-16 19:49:10 UTC
> 
>   FreeBSD src repository
> 
>   Modified files:
>     sys/netinet6         in6_src.c 
>   Log:
>   avoid exclusive sleep mutex.

1) This should be using TAILQ_FOREACH() to be more readable.

2) It's not safe to drop the lock here as you've done as the list can change 
out from under you.  You might be able to use TAILQ_FOREACH_SAFE() if you 
know what the next entry in the can't be removed from the list while the lock 
is dropped, but that's usually not an easy thing to ensure unless you set a 
flag or some such while holding the lock to communicate that to the code that 
adds and removes items to this list.  You may need to use an sx lock here 
rather than a mutex.

As it is, this change opens up a race condition that can result in deref'ing 
bogus pointers and kernel panics.

-- 
John Baldwin <jhb at FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org


More information about the cvs-all mailing list