From owner-svn-src-all@freebsd.org Sat Dec 16 20:19:01 2017 Return-Path: Delivered-To: svn-src-all@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 ABB4BE8D78A; Sat, 16 Dec 2017 20:19:01 +0000 (UTC) (envelope-from markj@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 769D47108C; Sat, 16 Dec 2017 20:19:01 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBGKJ0ek070892; Sat, 16 Dec 2017 20:19:00 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBGKJ0KZ070891; Sat, 16 Dec 2017 20:19:00 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201712162019.vBGKJ0KZ070891@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Sat, 16 Dec 2017 20:19:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326912 - head/usr.sbin/makefs X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/usr.sbin/makefs X-SVN-Commit-Revision: 326912 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Dec 2017 20:19:01 -0000 Author: markj Date: Sat Dec 16 20:19:00 2017 New Revision: 326912 URL: https://svnweb.freebsd.org/changeset/base/326912 Log: Fix a logic bug in makefs lazy inode initialization. We may need to initialize multiple inode blocks before writing a given inode. makefs(8) was only initializing a single block at a time, so certain inode allocation patterns could lead to a situation where it wrote an inode to an uninitialized block. That inode might be clobbered by a later initialization, resulting in a filesystem image containing directory entries that point to a seemingly unused inode. Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D13505 Modified: head/usr.sbin/makefs/ffs.c Modified: head/usr.sbin/makefs/ffs.c ============================================================================== --- head/usr.sbin/makefs/ffs.c Sat Dec 16 19:40:28 2017 (r326911) +++ head/usr.sbin/makefs/ffs.c Sat Dec 16 20:19:00 2017 (r326912) @@ -1130,7 +1130,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const * Initialize inode blocks on the fly for UFS2. */ initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap); - if (ffs_opts->version == 2 && cgino + INOPB(fs) > initediblk && + while (ffs_opts->version == 2 && cgino + INOPB(fs) > initediblk && initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) { memset(buf, 0, fs->fs_bsize); dip = (struct ufs2_dinode *)buf;