]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:57 +0000 (15:11 -0500)
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 <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_alloc.c

index 5205d5ce06bd3b4ff651231425e7f833b479ff0e..24db8152e624dfa9bd7acb6fd427ce5836466dda 100644 (file)
@@ -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;
 }