From: Darrick J. Wong Date: Thu, 7 Jan 2021 20:59:17 +0000 (-0500) Subject: xfs: detect overflows in bmbt records X-Git-Tag: v5.11.0-rc0~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92415d01728c022f13f1fc102957c6477f660a8c;p=thirdparty%2Fxfsprogs-dev.git xfs: detect overflows in bmbt records Source kernel commit: acf104c2331c1ba2a667e65dd36139d1555b1432 Detect file block mappings with a blockcount that's either so large that integer overflows occur or are zero, because neither are valid in the filesystem. Worse yet, attempting directory modifications causes the iext code to trip over the bmbt key handling and takes the filesystem down. We can fix most of this by preventing the bad metadata from entering the incore structures in the first place. Found by setting blockcount=0 in a directory data fork mapping and watching the fireworks. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index e0ca8b050..65cffb7b7 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -6222,6 +6222,11 @@ xfs_bmap_validate_extent( xfs_fsblock_t endfsb; bool isrt; + if (irec->br_startblock + irec->br_blockcount <= irec->br_startblock) + return __this_address; + if (irec->br_startoff + irec->br_blockcount <= irec->br_startoff) + return __this_address; + isrt = XFS_IS_REALTIME_INODE(ip); endfsb = irec->br_startblock + irec->br_blockcount - 1; if (isrt && whichfork == XFS_DATA_FORK) {