summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2018-06-13 14:57:24 +0000
committervisa <visa@openbsd.org>2018-06-13 14:57:24 +0000
commitb1caf6da48fa20cadf0aec13a254a8e1649fae47 (patch)
treeea4f106f1aad126789bc991368643a7fb6961c78
parentRemove #ifdef PASSWD, it was always enabled and is a leftover from krb5 days. (diff)
downloadwireguard-openbsd-b1caf6da48fa20cadf0aec13a254a8e1649fae47.tar.xz
wireguard-openbsd-b1caf6da48fa20cadf0aec13a254a8e1649fae47.zip
Make the VFS layer responsible for preventing the deletion
of mounted on directories. OK guenther@, mpi@
-rw-r--r--sys/kern/vfs_syscalls.c10
-rw-r--r--sys/nfs/nfs_serv.c9
-rw-r--r--sys/ufs/ufs/ufs_vnops.c6
3 files changed, 20 insertions, 5 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 477da52ee9b..82914681da8 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.287 2018/06/07 13:37:27 visa Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.288 2018/06/13 14:57:24 visa Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -1571,6 +1571,14 @@ dounlinkat(struct proc *p, int fd, const char *path, int flag)
}
/*
+ * A mounted on directory cannot be deleted.
+ */
+ if (vp->v_mountedhere != NULL) {
+ error = EBUSY;
+ goto out;
+ }
+
+ /*
* The root of a mounted filesystem cannot be deleted.
*/
if (vp->v_flag & VROOT)
diff --git a/sys/nfs/nfs_serv.c b/sys/nfs/nfs_serv.c
index 3fd59472076..0710a594c37 100644
--- a/sys/nfs/nfs_serv.c
+++ b/sys/nfs/nfs_serv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_serv.c,v 1.115 2018/06/07 13:37:28 visa Exp $ */
+/* $OpenBSD: nfs_serv.c,v 1.116 2018/06/13 14:57:24 visa Exp $ */
/* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */
/*
@@ -1979,6 +1979,13 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
goto out;
}
/*
+ * A mounted on directory cannot be deleted.
+ */
+ if (vp->v_mountedhere != NULL) {
+ error = EBUSY;
+ goto out;
+ }
+ /*
* The root of a mounted filesystem cannot be deleted.
*/
if (vp->v_flag & VROOT)
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index af02be00587..b984a4c1c89 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_vnops.c,v 1.140 2018/06/07 13:37:28 visa Exp $ */
+/* $OpenBSD: ufs_vnops.c,v 1.141 2018/06/13 14:57:24 visa Exp $ */
/* $NetBSD: ufs_vnops.c,v 1.18 1996/05/11 18:28:04 mycroft Exp $ */
/*
@@ -1293,9 +1293,9 @@ ufs_rmdir(void *v)
ip = VTOI(vp);
dp = VTOI(dvp);
/*
- * No rmdir "." or of mounted on directories.
+ * No rmdir ".".
*/
- if (dp == ip || vp->v_mountedhere != NULL) {
+ if (dp == ip) {
if (dp == ip)
vrele(dvp);
else