Skip to content

Commit

Permalink
xfs: don't crash if reading a directory results in an unexpected hole
Browse files Browse the repository at this point in the history
In xfs_dir3_data_read, we can encounter the situation where err == 0 and
*bpp == NULL if the given bno offset happens to be a hole; this leads to
a crash if we try to set the buffer type after the _da_read_buf call.
Holes can happen due to corrupt or malicious entries in the bmbt data,
so be a little more careful when we're handling buffers.

Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
  • Loading branch information
djwong authored and dchinner committed Dec 5, 2016
1 parent 356a322 commit 96a3aef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/xfs/libxfs/xfs_dir2_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ xfs_dir3_data_read(

err = xfs_da_read_buf(tp, dp, bno, mapped_bno, bpp,
XFS_DATA_FORK, &xfs_dir3_data_buf_ops);
if (!err && tp)
if (!err && tp && *bpp)
xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_DATA_BUF);
return err;
}
Expand Down

0 comments on commit 96a3aef

Please sign in to comment.