Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 2017 15:08:18 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323314 - in head/sbin/geom: class/virstor misc
Message-ID:  <201709081508.v88F8IaB085346@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Fri Sep  8 15:08:17 2017
New Revision: 323314
URL: https://svnweb.freebsd.org/changeset/base/323314

Log:
  Audit userspace geom code for leaking memory to disk
  
  Any geom class using g_metadata_store, as well as geom_virstor which
  duplicated g_metadata_store internally, would dump sectorsize - mdsize bytes
  of userspace memory following the metadata block stored. This is most or all
  geom classes (gcache, gconcat, geli, gjournal, glabel, gmirror, gmultipath,
  graid3, gshsec, gstripe, and geom_virstor).
  
  PR:		222077 (comment #3)
  Reported by:	Maxim Khitrov <max AT mxcrypt.com>
  Reviewed by:	des
  Security:	yes
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D12269

Modified:
  head/sbin/geom/class/virstor/geom_virstor.c
  head/sbin/geom/misc/subr.c

Modified: head/sbin/geom/class/virstor/geom_virstor.c
==============================================================================
--- head/sbin/geom/class/virstor/geom_virstor.c	Fri Sep  8 14:56:26 2017	(r323313)
+++ head/sbin/geom/class/virstor/geom_virstor.c	Fri Sep  8 15:08:17 2017	(r323314)
@@ -183,6 +183,7 @@ my_g_metadata_store(const char *name, u_char *md, size
 		goto out;
 	}
 	bcopy(md, sector, size);
+	bzero(sector + size, sectorsize - size);
 	if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
 	    (ssize_t)sectorsize) {
 		error = errno;

Modified: head/sbin/geom/misc/subr.c
==============================================================================
--- head/sbin/geom/misc/subr.c	Fri Sep  8 14:56:26 2017	(r323313)
+++ head/sbin/geom/misc/subr.c	Fri Sep  8 15:08:17 2017	(r323314)
@@ -302,6 +302,7 @@ g_metadata_store(const char *name, const unsigned char
 		goto out;
 	}
 	bcopy(md, sector, size);
+	bzero(sector + size, sectorsize - size);
 	if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
 	    sectorsize) {
 		error = errno;



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