From owner-svn-src-head@freebsd.org Sun May 17 14:10:47 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 342622DA9EE; Sun, 17 May 2020 14:10:47 +0000 (UTC) (envelope-from fsu@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49Q3vq0ZXJz4PLr; Sun, 17 May 2020 14:10:47 +0000 (UTC) (envelope-from fsu@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 0EF0A119AB; Sun, 17 May 2020 14:10:47 +0000 (UTC) (envelope-from fsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04HEAk5u036512; Sun, 17 May 2020 14:10:46 GMT (envelope-from fsu@FreeBSD.org) Received: (from fsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04HEAkXQ036511; Sun, 17 May 2020 14:10:46 GMT (envelope-from fsu@FreeBSD.org) Message-Id: <202005171410.04HEAkXQ036511@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fsu set sender to fsu@FreeBSD.org using -f From: Fedor Uporov Date: Sun, 17 May 2020 14:10:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361135 - head/sys/fs/ext2fs X-SVN-Group: head X-SVN-Commit-Author: fsu X-SVN-Commit-Paths: head/sys/fs/ext2fs X-SVN-Commit-Revision: 361135 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.33 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: Sun, 17 May 2020 14:10:47 -0000 Author: fsu Date: Sun May 17 14:10:46 2020 New Revision: 361135 URL: https://svnweb.freebsd.org/changeset/base/361135 Log: Restrict the max runp and runb return values in case of extents mapping. This restriction already present in case of indirect mapping, do the same in case of extents. PR: 246182 Reported by: Teran McKinney MFC after: 2 weeks Modified: head/sys/fs/ext2fs/ext2_bmap.c Modified: head/sys/fs/ext2fs/ext2_bmap.c ============================================================================== --- head/sys/fs/ext2fs/ext2_bmap.c Sun May 17 14:03:13 2020 (r361134) +++ head/sys/fs/ext2fs/ext2_bmap.c Sun May 17 14:10:46 2020 (r361135) @@ -94,21 +94,28 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn { struct inode *ip; struct m_ext2fs *fs; + struct mount *mp; + struct ext2mount *ump; struct ext4_extent_header *ehp; struct ext4_extent *ep; struct ext4_extent_path *path = NULL; daddr_t lbn; - int error, depth; + int error, depth, maxrun = 0, bsize; ip = VTOI(vp); fs = ip->i_e2fs; + mp = vp->v_mount; + ump = VFSTOEXT2(mp); lbn = bn; ehp = (struct ext4_extent_header *)ip->i_data; depth = ehp->eh_depth; + bsize = EXT2_BLOCK_SIZE(ump->um_e2fs); *bnp = -1; - if (runp != NULL) + if (runp != NULL) { + maxrun = mp->mnt_iosize_max / bsize - 1; *runp = 0; + } if (runb != NULL) *runb = 0; @@ -119,18 +126,21 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bn ep = path[depth].ep_ext; if(ep) { if (lbn < ep->e_blk) { - if (runp != NULL) - *runp = ep->e_blk - lbn - 1; + if (runp != NULL) { + *runp = min(maxrun, ep->e_blk - lbn - 1); + } } else if (ep->e_blk <= lbn && lbn < ep->e_blk + ep->e_len) { *bnp = fsbtodb(fs, lbn - ep->e_blk + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - if (runp != NULL) - *runp = ep->e_len - (lbn - ep->e_blk) - 1; + if (runp != NULL) { + *runp = min(maxrun, + ep->e_len - (lbn - ep->e_blk) - 1); + } if (runb != NULL) - *runb = lbn - ep->e_blk; + *runb = min(maxrun, lbn - ep->e_blk); } else { if (runb != NULL) - *runb = ep->e_blk + lbn - ep->e_len; + *runb = min(maxrun, ep->e_blk + lbn - ep->e_len); } }