summaryrefslogtreecommitdiffstats
path: root/sys/nfsclient
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/nfsclient
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/nfsclient')
-rw-r--r--sys/nfsclient/bootp_subr.c2
-rw-r--r--sys/nfsclient/nfs_vfsops.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
index 77c7739..7f65fe2 100644
--- a/sys/nfsclient/bootp_subr.c
+++ b/sys/nfsclient/bootp_subr.c
@@ -1569,8 +1569,10 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx,
printf("hostname %s (ignored) ", p);
} else {
strcpy(nd->my_hostnam, p);
+ mtx_lock(&hostname_mtx);
strcpy(hostname, p);
printf("hostname %s ", hostname);
+ mtx_unlock(&hostname_mtx);
gctx->sethostname = ifctx;
}
}
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
index 17536491..c21b48e 100644
--- a/sys/nfsclient/nfs_vfsops.c
+++ b/sys/nfsclient/nfs_vfsops.c
@@ -506,11 +506,13 @@ nfs_mountroot(struct mount *mp, struct thread *td)
* set hostname here and then let the "/etc/rc.xxx" files
* mount the right /var based upon its preset value.
*/
+ mtx_lock(&hostname_mtx);
bcopy(nd->my_hostnam, hostname, MAXHOSTNAMELEN);
hostname[MAXHOSTNAMELEN - 1] = '\0';
for (i = 0; i < MAXHOSTNAMELEN; i++)
if (hostname[i] == '\0')
break;
+ mtx_unlock(&hostname_mtx);
inittodr(ntohl(nd->root_time));
return (0);
}
OpenPOWER on IntegriCloud