From owner-svn-src-head@freebsd.org Sat Dec 15 18:35:48 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 EC3001329F52; Sat, 15 Dec 2018 18:35:47 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C7888418F; Sat, 15 Dec 2018 18:35:47 +0000 (UTC) (envelope-from mckusick@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 787F51B82E; Sat, 15 Dec 2018 18:35:47 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBFIZlLh081292; Sat, 15 Dec 2018 18:35:47 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBFIZlDU081291; Sat, 15 Dec 2018 18:35:47 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201812151835.wBFIZlDU081291@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sat, 15 Dec 2018 18:35:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342133 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 342133 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8C7888418F X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.80 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.989,0]; NEURAL_HAM_SHORT(-0.93)[-0.930,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-0.88)[-0.883,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Sat, 15 Dec 2018 18:35:48 -0000 Author: mckusick Date: Sat Dec 15 18:35:46 2018 New Revision: 342133 URL: https://svnweb.freebsd.org/changeset/base/342133 Log: Reorder ffs_verify_dinode_ckhash() so that it checks the inode check-hash before copying in the inode so that the mode and link-count are not set if the check-hash fails. This change ensures that the vnode will be properly unwound and recycled rather than being held in the cache. Initialize the file mode is zero so that if the loading of the inode fails (for example because of a check-hash failure), the vnode will be properly unwound and recycled. Reported by: Gary Jennejohn (gj) Sponsored by: Netflix Modified: head/sys/ufs/ffs/ffs_subr.c head/sys/ufs/ffs/ffs_vfsops.c Modified: head/sys/ufs/ffs/ffs_subr.c ============================================================================== --- head/sys/ufs/ffs/ffs_subr.c Sat Dec 15 18:11:41 2018 (r342132) +++ head/sys/ufs/ffs/ffs_subr.c Sat Dec 15 18:35:46 2018 (r342133) @@ -135,8 +135,14 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struc ip->i_gid = dip1->di_gid; return (0); } + dip2 = ((struct ufs2_dinode *)bp->b_data + ino_to_fsbo(fs, ino)); + if ((error = ffs_verify_dinode_ckhash(fs, dip2)) != 0) { + printf("%s: inode %jd: check-hash failed\n", fs->fs_fsmnt, + (intmax_t)ino); + return (error); + } + *ip->i_din2 = *dip2; dip2 = ip->i_din2; - *dip2 = *((struct ufs2_dinode *)bp->b_data + ino_to_fsbo(fs, ino)); ip->i_mode = dip2->di_mode; ip->i_nlink = dip2->di_nlink; ip->i_effnlink = dip2->di_nlink; @@ -145,9 +151,7 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struc ip->i_gen = dip2->di_gen; ip->i_uid = dip2->di_uid; ip->i_gid = dip2->di_gid; - if ((error = ffs_verify_dinode_ckhash(fs, dip2)) != 0) - printf("Inode %jd: check-hash failed\n", (intmax_t)ino); - return (error); + return (0); } #endif /* _KERNEL */ Modified: head/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vfsops.c Sat Dec 15 18:11:41 2018 (r342132) +++ head/sys/ufs/ffs/ffs_vfsops.c Sat Dec 15 18:35:46 2018 (r342133) @@ -1692,6 +1692,7 @@ ffs_vgetf(mp, ino, flags, vpp, ffs_flags) ip->i_ea_refs = 0; ip->i_nextclustercg = -1; ip->i_flag = fs->fs_magic == FS_UFS1_MAGIC ? 0 : IN_UFS2; + ip->i_mode = 0; /* ensure error cases below throw away vnode */ #ifdef QUOTA { int i;