From a2e5b9cfbd50117e35e6a895dc523efcc4631c22 Mon Sep 17 00:00:00 2001 From: dcoppa Date: Thu, 4 Dec 2014 08:19:03 +0000 Subject: 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@ --- sys/tmpfs/tmpfs_subr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/tmpfs') 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); -- cgit v1.2.3-59-g8ed1b