mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
xfs: add bounds checking to xfs_rt{bitmap,summary}_read_buf
Add a corruption check for passing an invalid block number, which is a lot easier to understand than the xfs_bmapi_read failure later on. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
This commit is contained in:
parent
6d2db12d56
commit
b4781eea68
|
|
@ -69,7 +69,7 @@ xfs_rtbuf_cache_relse(
|
|||
* Get a buffer for the bitmap or summary file block specified.
|
||||
* The buffer is returned read and locked.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
xfs_rtbuf_get(
|
||||
struct xfs_rtalloc_args *args,
|
||||
xfs_fileoff_t block, /* block number in bitmap or summary */
|
||||
|
|
@ -138,6 +138,35 @@ xfs_rtbuf_get(
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
xfs_rtbitmap_read_buf(
|
||||
struct xfs_rtalloc_args *args,
|
||||
xfs_fileoff_t block)
|
||||
{
|
||||
struct xfs_mount *mp = args->mp;
|
||||
|
||||
if (XFS_IS_CORRUPT(mp, block >= mp->m_sb.sb_rbmblocks)) {
|
||||
xfs_rt_mark_sick(mp, XFS_SICK_RT_BITMAP);
|
||||
return -EFSCORRUPTED;
|
||||
}
|
||||
|
||||
return xfs_rtbuf_get(args, block, 0);
|
||||
}
|
||||
|
||||
int
|
||||
xfs_rtsummary_read_buf(
|
||||
struct xfs_rtalloc_args *args,
|
||||
xfs_fileoff_t block)
|
||||
{
|
||||
struct xfs_mount *mp = args->mp;
|
||||
|
||||
if (XFS_IS_CORRUPT(mp, block >= XFS_B_TO_FSB(mp, mp->m_rsumsize))) {
|
||||
xfs_rt_mark_sick(args->mp, XFS_SICK_RT_SUMMARY);
|
||||
return -EFSCORRUPTED;
|
||||
}
|
||||
return xfs_rtbuf_get(args, block, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Searching backward from start find the first block whose allocated/free state
|
||||
* is different from start's.
|
||||
|
|
|
|||
|
|
@ -293,26 +293,8 @@ typedef int (*xfs_rtalloc_query_range_fn)(
|
|||
|
||||
#ifdef CONFIG_XFS_RT
|
||||
void xfs_rtbuf_cache_relse(struct xfs_rtalloc_args *args);
|
||||
|
||||
int xfs_rtbuf_get(struct xfs_rtalloc_args *args, xfs_fileoff_t block,
|
||||
int issum);
|
||||
|
||||
static inline int
|
||||
xfs_rtbitmap_read_buf(
|
||||
struct xfs_rtalloc_args *args,
|
||||
xfs_fileoff_t block)
|
||||
{
|
||||
return xfs_rtbuf_get(args, block, 0);
|
||||
}
|
||||
|
||||
static inline int
|
||||
xfs_rtsummary_read_buf(
|
||||
struct xfs_rtalloc_args *args,
|
||||
xfs_fileoff_t block)
|
||||
{
|
||||
return xfs_rtbuf_get(args, block, 1);
|
||||
}
|
||||
|
||||
int xfs_rtbitmap_read_buf(struct xfs_rtalloc_args *args, xfs_fileoff_t block);
|
||||
int xfs_rtsummary_read_buf(struct xfs_rtalloc_args *args, xfs_fileoff_t block);
|
||||
int xfs_rtcheck_range(struct xfs_rtalloc_args *args, xfs_rtxnum_t start,
|
||||
xfs_rtxlen_t len, int val, xfs_rtxnum_t *new, int *stat);
|
||||
int xfs_rtfind_back(struct xfs_rtalloc_args *args, xfs_rtxnum_t start,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user