Date: Fri, 12 Jun 2020 13:54:42 +0000 (UTC) From: Fedor Uporov <fsu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362098 - stable/12/sys/fs/ext2fs Message-ID: <202006121354.05CDsgrn095234@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: fsu Date: Fri Jun 12 13:54:41 2020 New Revision: 362098 URL: https://svnweb.freebsd.org/changeset/base/362098 Log: MFC r361135: 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 Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c Modified: stable/12/sys/fs/ext2fs/ext2_bmap.c ============================================================================== --- stable/12/sys/fs/ext2fs/ext2_bmap.c Fri Jun 12 13:53:50 2020 (r362097) +++ stable/12/sys/fs/ext2fs/ext2_bmap.c Fri Jun 12 13:54:41 2020 (r362098) @@ -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); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006121354.05CDsgrn095234>