summaryrefslogtreecommitdiffstats
path: root/sys/tmpfs
diff options
context:
space:
mode:
authordcoppa <dcoppa@openbsd.org>2014-12-04 08:19:03 +0000
committerdcoppa <dcoppa@openbsd.org>2014-12-04 08:19:03 +0000
commita2e5b9cfbd50117e35e6a895dc523efcc4631c22 (patch)
tree5b947d7092d079bb683637d4c6213ac96bb81759 /sys/tmpfs
parentSimplify the MSI bits a bit. (diff)
downloadwireguard-openbsd-a2e5b9cfbd50117e35e6a895dc523efcc4631c22.tar.xz
wireguard-openbsd-a2e5b9cfbd50117e35e6a895dc523efcc4631c22.zip
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')
-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);