From: Darrick J. Wong Date: Thu, 28 Jun 2018 20:11:57 +0000 (-0500) Subject: xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption X-Git-Tag: v4.18.0-rc0~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3741f971f3c99d00ee9bb61dded0a1e049045c8b;p=thirdparty%2Fxfsprogs-dev.git xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption Source kernel commit: a37f7b127ed3dcfab3edc105482891711c1966b3 Return -EFSCORRUPTED when the bnobt/cntbt return obviously corrupt values, rather than letting them bounce around in the internal code. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_alloc.c b/libxfs/xfs_alloc.c index 5205d5ce0..24db8152e 100644 --- a/libxfs/xfs_alloc.c +++ b/libxfs/xfs_alloc.c @@ -227,10 +227,14 @@ xfs_alloc_get_rec( int error; error = xfs_btree_get_rec(cur, &rec, stat); - if (!error && *stat == 1) { - *bno = be32_to_cpu(rec->alloc.ar_startblock); - *len = be32_to_cpu(rec->alloc.ar_blockcount); - } + if (error || !(*stat)) + return error; + if (rec->alloc.ar_blockcount == 0) + return -EFSCORRUPTED; + + *bno = be32_to_cpu(rec->alloc.ar_startblock); + *len = be32_to_cpu(rec->alloc.ar_blockcount); + return error; }