Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Sep 2019 17:16:21 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r352692 - releng/12.1/sys/fs/msdosfs
Message-ID:  <201909251716.x8PHGLTm052752@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Sep 25 17:16:21 2019
New Revision: 352692
URL: https://svnweb.freebsd.org/changeset/base/352692

Log:
  MFS r352678: msdosfs: do not deget unlinked denodes
  
  When a file is unlinked, the denode is not reclaimed until the last
  reference is dropped, but the directory entry is immediately up for reuse.
  This is a problem later when createde goes to grab a denode for the newly
  created entry -- we search the hash and find a dead denode, then return that
  without even bumping the reference count and the data later gets truncated
  when the the last reference to the unlinked file is dropped.
  
  This manifested itself as a broken in-place strip(1) on msdosfs.
  
  The comment indicating that we want to skip these denodes has been updated
  to reflect where this is actually done.
  
  Approved by:	re (gjb)

Modified:
  releng/12.1/sys/fs/msdosfs/msdosfs_denode.c
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- releng/12.1/sys/fs/msdosfs/msdosfs_denode.c	Wed Sep 25 17:14:43 2019	(r352691)
+++ releng/12.1/sys/fs/msdosfs/msdosfs_denode.c	Wed Sep 25 17:16:21 2019	(r352692)
@@ -79,7 +79,7 @@ de_vncmpf(struct vnode *vp, void *arg)
 
 	a = arg;
 	de = VTODE(vp);
-	return (de->de_inode != *a);
+	return (de->de_inode != *a) || (de->de_refcnt <= 0);
 }
 
 /*
@@ -124,8 +124,9 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_lon
 	 * address of "." entry. For root dir (if not FAT32) use cluster
 	 * MSDOSFSROOT, offset MSDOSFSROOT_OFS
 	 *
-	 * NOTE: The check for de_refcnt > 0 below insures the denode being
-	 * examined does not represent an unlinked but still open file.
+	 * NOTE: de_vncmpf will explicitly skip any denodes that do not have
+	 * a de_refcnt > 0.  This insures that that we do not attempt to use
+	 * a denode that represents an unlinked but still open file.
 	 * These files are not to be accessible even when the directory
 	 * entry that represented the file happens to be reused while the
 	 * deleted file is still open.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909251716.x8PHGLTm052752>