Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Aug 2019 18:10:34 +0000 (UTC)
From:      Kirk McKusick <mckusick@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350651 - head/sys/ufs/ffs
Message-ID:  <201908061810.x76IAYRA076013@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mckusick
Date: Tue Aug  6 18:10:34 2019
New Revision: 350651
URL: https://svnweb.freebsd.org/changeset/base/350651

Log:
  A race condition existed between the time a UFS/FFS superblock check
  hash was computed and the time that the superblock was copied to a
  buffer to be written to disk. The result was a failed superblock
  check hash the next time that the superblock was read.
  
  The fix is to compute the check hash after the superblock has been
  copied to a buffer to be written.
  
  PR:           236504
  Reported by:  Peter Holm
  Tested by:    Peter Holm
  Sponsored by: Netflix

Modified:
  head/sys/ufs/ffs/ffs_vfsops.c

Modified: head/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vfsops.c	Tue Aug  6 17:15:46 2019	(r350650)
+++ head/sys/ufs/ffs/ffs_vfsops.c	Tue Aug  6 18:10:34 2019	(r350651)
@@ -1998,7 +1998,13 @@ ffs_use_bwrite(void *devfd, off_t loc, void *buf, int 
 	if (MOUNTEDSOFTDEP(ump->um_mountp))
 		softdep_setup_sbupdate(ump, (struct fs *)bp->b_data, bp);
 	bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
-	ffs_oldfscompat_write((struct fs *)bp->b_data, ump);
+	fs = (struct fs *)bp->b_data;
+	ffs_oldfscompat_write(fs, ump);
+	/*
+	 * Because we may have made changes to the superblock, we need to
+	 * recompute its check-hash.
+	 */
+	fs->fs_ckhash = ffs_calc_sbhash(fs);
 	if (devfdp->suspended)
 		bp->b_flags |= B_VALIDSUSPWRT;
 	if (devfdp->waitfor != MNT_WAIT)



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