diff options
author | andre <andre@FreeBSD.org> | 2004-10-19 22:08:13 +0000 |
---|---|---|
committer | andre <andre@FreeBSD.org> | 2004-10-19 22:08:13 +0000 |
commit | 952f79699990e2a72bc72acf195a21d4170d63b1 (patch) | |
tree | f9cacbc5c25d2fd75d2776699bf496dc40195ff9 /sys/netinet/ip_divert.c | |
parent | 009582eb77dda55209d02e40d2b836050bda1e17 (diff) | |
download | FreeBSD-src-952f79699990e2a72bc72acf195a21d4170d63b1.zip FreeBSD-src-952f79699990e2a72bc72acf195a21d4170d63b1.tar.gz |
Slightly extend the locking during unload to fully cover the protocol
deregistration. This does not entirely close the race but narrows the
even previously extremely small chance of a race some more.
Diffstat (limited to 'sys/netinet/ip_divert.c')
-rw-r--r-- | sys/netinet/ip_divert.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index b2161cf..01ade1a 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -694,19 +694,20 @@ div_modevent(module_t mod, int type, void *unused) * connected. Maybe this can be changed later to forcefully * disconnect any open sockets. * - * XXXRW: Note that there is a slight race here, as a socket - * could be opened between when we test and when we - * unregister. + * XXXRW: Note that there is a slight race here, as a new + * socket open request could be spinning on the lock and then + * we destroy the lock. */ - INP_INFO_RLOCK(&divcbinfo); + INP_INFO_WLOCK(&divcbinfo); n = divcbinfo.ipi_count; - INP_INFO_RUNLOCK(&divcbinfo); if (n != 0) { err = EBUSY; + INP_INFO_WUNLOCK(&divcbinfo); break; } ip_divert_ptr = NULL; err = pf_proto_unregister(PF_INET, IPPROTO_DIVERT, SOCK_RAW); + INP_INFO_WUNLOCK(&divcbinfo); INP_INFO_LOCK_DESTROY(&divcbinfo); break; default: |