summaryrefslogtreecommitdiffstats
path: root/sys/rpc
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2008-07-05 13:10:10 +0000
committerrwatson <rwatson@FreeBSD.org>2008-07-05 13:10:10 +0000
commit051819b84758e212ecd632e9bd6f47e70f37aa3a (patch)
treefcde383ade7af0060da3dd095039791d9e423bee /sys/rpc
parentb754e07b66100e4e4d6ac8caa8f6302730552936 (diff)
downloadFreeBSD-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/rpc')
-rw-r--r--sys/rpc/authunix_prot.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/rpc/authunix_prot.c b/sys/rpc/authunix_prot.c
index 141f594..b229fb3 100644
--- a/sys/rpc/authunix_prot.c
+++ b/sys/rpc/authunix_prot.c
@@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/systm.h>
#include <sys/ucred.h>
@@ -67,6 +69,7 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred)
uint32_t ngroups, i;
uint32_t junk;
+ mtx_lock(&hostname_mtx);
if (xdrs->x_op == XDR_ENCODE) {
/*
* Restrict name length to 255 according to RFC 1057.
@@ -92,6 +95,7 @@ xdr_authunix_parms(XDR *xdrs, uint32_t *time, struct xucred *cred)
} else {
xdr_setpos(xdrs, xdr_getpos(xdrs) + RNDUP(namelen));
}
+ mtx_unlock(&hostname_mtx);
if (!xdr_uint32_t(xdrs, &cred->cr_uid))
return (FALSE);
OpenPOWER on IntegriCloud