svn commit: r351215 - head/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Mon Aug 19 14:11:55 UTC 2019


Author: mjg
Date: Mon Aug 19 14:11:54 2019
New Revision: 351215
URL: https://svnweb.freebsd.org/changeset/base/351215

Log:
  vfs: fix up r351193 ("stop always overwriting ->mnt_stat in VFS_STATFS")
  
  fs-specific part of vfs_statfs routines only fill in small portion of the
  structure. Previous code was always copying everything at a higher layer to
  acoomodate it and this patch does the same.
  
  'df' (no arguments) worked fine because the caller uses mnt_stat itself as the
  target buffer, making all the copying a no-op for its own case.
  'df /' and similar use a different consumer which passes its own buffer and
  this is where you can run into trouble.
  
  Reported by:	cy
  Fixes: r351193
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_mount.c

Modified: head/sys/kern/vfs_mount.c
==============================================================================
--- head/sys/kern/vfs_mount.c	Mon Aug 19 12:42:03 2019	(r351214)
+++ head/sys/kern/vfs_mount.c	Mon Aug 19 14:11:54 2019	(r351215)
@@ -1833,6 +1833,12 @@ __vfs_statfs(struct mount *mp, struct statfs *sbp)
 {
 
 	/*
+	 * Filesystems only fill in part of the structure for updates, we
+	 * have to read the entirety first to get all content.
+	 */
+	memcpy(sbp, &mp->mnt_stat, sizeof(*sbp));
+
+	/*
 	 * Set these in case the underlying filesystem fails to do so.
 	 */
 	sbp->f_version = STATFS_VERSION;


More information about the svn-src-all mailing list