diff options
author | rwatson <rwatson@FreeBSD.org> | 2008-07-05 13:10:10 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2008-07-05 13:10:10 +0000 |
commit | 051819b84758e212ecd632e9bd6f47e70f37aa3a (patch) | |
tree | fcde383ade7af0060da3dd095039791d9e423bee /sys/i386/ibcs2/ibcs2_socksys.c | |
parent | b754e07b66100e4e4d6ac8caa8f6302730552936 (diff) | |
download | FreeBSD-src-051819b84758e212ecd632e9bd6f47e70f37aa3a.zip FreeBSD-src-051819b84758e212ecd632e9bd6f47e70f37aa3a.tar.gz |
Introduce a new lock, hostname_mtx, and use it to synchronize access
to global hostname and domainname variables. Where necessary, copy
to or from a stack-local buffer before performing copyin() or
copyout(). A few uses, such as in cd9660 and daemon_saver, remain
under-synchronized and will require further updates.
Correct a bug in which a failed copyin() of domainname would leave
domainname potentially corrupted.
MFC after: 3 weeks
Diffstat (limited to 'sys/i386/ibcs2/ibcs2_socksys.c')
-rw-r--r-- | sys/i386/ibcs2/ibcs2_socksys.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c index f4939cf..62d300f 100644 --- a/sys/i386/ibcs2/ibcs2_socksys.c +++ b/sys/i386/ibcs2/ibcs2_socksys.c @@ -31,6 +31,8 @@ __FBSDID("$FreeBSD$"); #include <sys/sysproto.h> #include <sys/jail.h> #include <sys/kernel.h> +#include <sys/lock.h> +#include <sys/mutex.h> #include <sys/sysctl.h> #include <i386/ibcs2/ibcs2_socksys.h> @@ -175,11 +177,15 @@ ibcs2_setipdomainname(td, uap) int error, sctl[2], hlen; /* W/out a hostname a domain-name is nonsense */ - if ( strlen(hostname) == 0 ) + mtx_lock(&hostname_mtx); + if ( strlen(hostname) == 0 ) { + mtx_unlock(&hostname_mtx); return EINVAL; + } /* Get the host's unqualified name (strip off the domain) */ snprintf(hname, sizeof(hname), "%s", hostname); + mtx_unlock(&hostname_mtx); ptr = index(hname, '.'); if ( ptr != NULL ) { ptr++; |