Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Sep 2019 12:58:50 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r352678 - in stable: 11/sys/fs/msdosfs 12/sys/fs/msdosfs
Message-ID:  <201909251258.x8PCwoFU098944@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Sep 25 12:58:49 2019
New Revision: 352678
URL: https://svnweb.freebsd.org/changeset/base/352678

Log:
  MFC r352564: 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.

Modified:
  stable/12/sys/fs/msdosfs/msdosfs_denode.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/fs/msdosfs/msdosfs_denode.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/fs/msdosfs/msdosfs_denode.c
==============================================================================
--- stable/12/sys/fs/msdosfs/msdosfs_denode.c	Wed Sep 25 11:58:54 2019	(r352677)
+++ stable/12/sys/fs/msdosfs/msdosfs_denode.c	Wed Sep 25 12:58:49 2019	(r352678)
@@ -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?201909251258.x8PCwoFU098944>