Skip to content

Commit 3148ebf

Browse files
Dave Chinnerdchinner
authored andcommitted
xfs: validity check agbnos on the AGFL
If the agfl or the indexing in the AGF has been corrupted, getting a block form the AGFL could return an invalid block number. If this happens, bad things happen. Check the agbno we pull off the AGFL and return -EFSCORRUPTED if we find somethign bad. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent e0a8de7 commit 3148ebf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,9 @@ xfs_alloc_get_freelist(
27802780
*/
27812781
agfl_bno = xfs_buf_to_agfl_bno(agflbp);
27822782
bno = be32_to_cpu(agfl_bno[be32_to_cpu(agf->agf_flfirst)]);
2783+
if (XFS_IS_CORRUPT(tp->t_mountp, !xfs_verify_agbno(pag, bno)))
2784+
return -EFSCORRUPTED;
2785+
27832786
be32_add_cpu(&agf->agf_flfirst, 1);
27842787
xfs_trans_brelse(tp, agflbp);
27852788
if (be32_to_cpu(agf->agf_flfirst) == xfs_agfl_size(mp))

0 commit comments

Comments
 (0)