From owner-svn-src-head@freebsd.org Mon Jun 11 19:12:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA0A0100A4DC; Mon, 11 Jun 2018 19:12:51 +0000 (UTC) (envelope-from db@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C9FB77877; Mon, 11 Jun 2018 19:12:51 +0000 (UTC) (envelope-from db@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4E2381F9A1; Mon, 11 Jun 2018 19:12:51 +0000 (UTC) (envelope-from db@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BJCpXY036325; Mon, 11 Jun 2018 19:12:51 GMT (envelope-from db@FreeBSD.org) Received: (from db@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5BJCpob036324; Mon, 11 Jun 2018 19:12:51 GMT (envelope-from db@FreeBSD.org) Message-Id: <201806111912.w5BJCpob036324@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: db set sender to db@FreeBSD.org using -f From: Diane Bruce Date: Mon, 11 Jun 2018 19:12:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334968 - head/sbin/dump X-SVN-Group: head X-SVN-Commit-Author: db X-SVN-Commit-Paths: head/sbin/dump X-SVN-Commit-Revision: 334968 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.26 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: Mon, 11 Jun 2018 19:12:51 -0000 Author: db (ports committer) Date: Mon Jun 11 19:12:50 2018 New Revision: 334968 URL: https://svnweb.freebsd.org/changeset/base/334968 Log: Large file systems with inodes > 512K have been silently overflowing c_addr in spcl. So check before we start dumping otherwise we can end up with a corrupted dump. PR: 228807 Submitted by: db Reviewed by: imp Approved by: imp Modified: head/sbin/dump/main.c (contents, props changed) Modified: head/sbin/dump/main.c ============================================================================== --- head/sbin/dump/main.c Mon Jun 11 19:03:49 2018 (r334967) +++ head/sbin/dump/main.c Mon Jun 11 19:12:50 2018 (r334968) @@ -103,6 +103,7 @@ main(int argc, char *argv[]) int i, ret, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; int just_estimate = 0; ino_t maxino; + int c_count=0; char *tmsg; spcl.c_date = _time_to_time64(time(NULL)); @@ -433,7 +434,6 @@ main(int argc, char *argv[]) msgtail("to %s\n", tape); sync(); - sblock = NULL; if ((ret = sbget(diskfd, &sblock, -1)) != 0) { switch (ret) { case ENOENT: @@ -453,6 +453,9 @@ main(int argc, char *argv[]) quit("TP_BSIZE (%d) is not a power of 2", TP_BSIZE); maxino = sblock->fs_ipg * sblock->fs_ncg; mapsize = roundup(howmany(maxino, CHAR_BIT), TP_BSIZE); + c_count = howmany(mapsize * sizeof(char), TP_BSIZE); + if (c_count > TP_NINDIR) + quit("fs is too large for dump!"); usedinomap = (char *)calloc((unsigned) mapsize, sizeof(char)); dumpdirmap = (char *)calloc((unsigned) mapsize, sizeof(char)); dumpinomap = (char *)calloc((unsigned) mapsize, sizeof(char));