Bug 150143 - [patch][tmpfs] Source directory vnode can disappear before locking it in tmpfs_rename
Summary: [patch][tmpfs] Source directory vnode can disappear before locking it in tmpf...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-31 11:50 UTC by Gleb Kurtsou
Modified: 2010-09-07 23:50 UTC (History)
0 users

See Also:


Attachments
file.txt (973 bytes, text/plain)
2010-08-31 11:50 UTC, Gleb Kurtsou
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Kurtsou freebsd_committer freebsd_triage 2010-08-31 11:50:02 UTC
Source directory vnode can disappear before locking it in tmpfs_rename.

Fixes panic triggered by blogbench.

Also note that fdvp vnode locking order may be incorrect in tmpfs_rename, and thus rename is deadlock prone. It was initially incorrect, possible solution could be to lock all necessary vnodes similarly to ufs, but it seems not to work well with tmpfs.

Fix: Patch attached, tested by Ivan Voras

Patch attached with submission follows:
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2010-09-06 08:07:55 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 dfilter service freebsd_committer freebsd_triage 2010-09-07 23:41:09 UTC
Author: ivoras
Date: Tue Sep  7 22:40:45 2010
New Revision: 212305
URL: http://svn.freebsd.org/changeset/base/212305

Log:
  Avoid "Entry can disappear before we lock fdvp" panic.
  
  PR:		150143
  Submitted by:	Gleb Kurtsou <gk at FreeBSD.org>
  Pretty sure it won't blow up: mckusick
  MFC after:	2 weeks

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Sep  7 21:28:45 2010	(r212304)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c	Tue Sep  7 22:40:45 2010	(r212305)
@@ -981,10 +981,14 @@ tmpfs_rename(struct vop_rename_args *v)
 	fnode = VP_TO_TMPFS_NODE(fvp);
 	de = tmpfs_dir_lookup(fdnode, fnode, fcnp);
 
-	/* Avoid manipulating '.' and '..' entries. */
+	/* Entry can disappear before we lock fdvp,
+	 * also avoid manipulating '.' and '..' entries. */
 	if (de == NULL) {
-		MPASS(fvp->v_type == VDIR);
-		error = EINVAL;
+		if ((fcnp->cn_flags & ISDOTDOT) != 0 ||
+		    (fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.'))
+			error = EINVAL;
+		else
+			error = ENOENT;
 		goto out_locked;
 	}
 	MPASS(de->td_node == fnode);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Ivan Voras freebsd_committer freebsd_triage 2010-09-07 23:48:23 UTC
State Changed
From-To: open->closed

Committed. r212305.