summaryrefslogtreecommitdiff
path: root/sys/tmpfs/tmpfs_subr.c
diff options
context:
space:
mode:
authorDavid Coppa <dcoppa@cvs.openbsd.org>2014-12-04 08:19:04 +0000
committerDavid Coppa <dcoppa@cvs.openbsd.org>2014-12-04 08:19:04 +0000
commit0d8098fac5c39f73b2fd00bf595cf942e42d15d3 (patch)
tree134589c45b277acb5e06374397140a9e6b3b0785 /sys/tmpfs/tmpfs_subr.c
parent17fad98623f9e72c39e4d7de1b81daa41a3c4c0f (diff)
Disallow file allocations on directories that have been removed
(tn_links == 0). Failure to enforce such a check can lead to the violation of the assumption that removed directories should not contain directory entries and thus trigger a kernel diagnostic assertion (panic). Fix provided by Pedro Martelletto, thanks! OK millert@
Diffstat (limited to 'sys/tmpfs/tmpfs_subr.c')
-rw-r--r--sys/tmpfs/tmpfs_subr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/tmpfs/tmpfs_subr.c b/sys/tmpfs/tmpfs_subr.c
index 3e92d11dff0..baf119f5695 100644
--- a/sys/tmpfs/tmpfs_subr.c
+++ b/sys/tmpfs/tmpfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmpfs_subr.c,v 1.8 2014/11/18 02:37:31 tedu Exp $ */
+/* $OpenBSD: tmpfs_subr.c,v 1.9 2014/12/04 08:19:03 dcoppa Exp $ */
/* $NetBSD: tmpfs_subr.c,v 1.79 2012/03/13 18:40:50 elad Exp $ */
/*
@@ -398,6 +398,11 @@ tmpfs_alloc_file(struct vnode *dvp, struct vnode **vpp, struct vattr *vap,
goto out;
}
+ if (dnode->tn_links == 0) {
+ error = ENOENT;
+ goto out;
+ }
+
/* Allocate a node that represents the new file. */
error = tmpfs_alloc_node(tmp, vap->va_type, cnp->cn_cred->cr_uid,
dnode->tn_gid, vap->va_mode, target, vap->va_rdev, &node);