Author: mckusick
Date: Sat May  4 18:00:57 2019
New Revision: 347130
URL: https://svnweb.freebsd.org/changeset/base/347130

Log:
  Zero out the file directory entry metadata to reduce disk
  scavenging disclosure.
  
  Submitted by: David G. Lawrence <d...@dglawrence.com>
  MFC after:    1 week

Modified:
  head/sys/ufs/ufs/ufs_lookup.c

Modified: head/sys/ufs/ufs/ufs_lookup.c
==============================================================================
--- head/sys/ufs/ufs/ufs_lookup.c       Sat May  4 17:35:13 2019        
(r347129)
+++ head/sys/ufs/ufs/ufs_lookup.c       Sat May  4 18:00:57 2019        
(r347130)
@@ -1218,16 +1218,21 @@ ufs_dirremove(dvp, ip, flags, isrmdir)
        if (ip && rep->d_ino != ip->i_number)
                panic("ufs_dirremove: ip %ju does not match dirent ino %ju\n",
                    (uintmax_t)ip->i_number, (uintmax_t)rep->d_ino);
-       if (dp->i_count == 0) {
+       /*
+        * Zero out the file directory entry metadata to reduce disk
+        * scavenging disclosure.
+        */
+       bzero(&rep->d_name[0], rep->d_namlen);
+       rep->d_namlen = 0;
+       rep->d_type = 0;
+       rep->d_ino = 0;
+
+       if (dp->i_count != 0) {
                /*
-                * First entry in block: set d_ino to zero.
-                */
-               ep->d_ino = 0;
-       } else {
-               /*
                 * Collapse new free space into previous entry.
                 */
                ep->d_reclen += rep->d_reclen;
+               rep->d_reclen = 0;
        }
 #ifdef UFS_DIRHASH
        if (dp->i_dirhash != NULL)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to