From owner-svn-src-head@freebsd.org Fri Sep 8 15:08:19 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4C5B5E1CD49; Fri, 8 Sep 2017 15:08:19 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1A40382D1D; Fri, 8 Sep 2017 15:08:19 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v88F8IEc085348; Fri, 8 Sep 2017 15:08:18 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v88F8IaB085346; Fri, 8 Sep 2017 15:08:18 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201709081508.v88F8IaB085346@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Fri, 8 Sep 2017 15:08:18 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sbin/geom: class/virstor misc X-SVN-Commit-Revision: 323314 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 15:08:19 -0000 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 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;