mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
xfs: fix bounds check in xfs_defer_agfl_block()
[ Upstream commit2bed0d82c2] Need to happen before we allocate and then leak the xefi. Found by coverity via an xfsprogs libxfs scan. [djwong: This also fixes the type of the @agbno argument.] Fixes:7dfee17b13("xfs: validate block number being freed before adding to xefi") Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com> Acked-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
fa91c6969d
commit
ec35f7567b
@@ -2489,24 +2489,25 @@ static int
|
|||||||
xfs_defer_agfl_block(
|
xfs_defer_agfl_block(
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
xfs_agnumber_t agno,
|
||||||
xfs_fsblock_t agbno,
|
xfs_agblock_t agbno,
|
||||||
struct xfs_owner_info *oinfo)
|
struct xfs_owner_info *oinfo)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = tp->t_mountp;
|
struct xfs_mount *mp = tp->t_mountp;
|
||||||
struct xfs_extent_free_item *xefi;
|
struct xfs_extent_free_item *xefi;
|
||||||
|
xfs_fsblock_t fsbno = XFS_AGB_TO_FSB(mp, agno, agbno);
|
||||||
|
|
||||||
ASSERT(xfs_extfree_item_cache != NULL);
|
ASSERT(xfs_extfree_item_cache != NULL);
|
||||||
ASSERT(oinfo != NULL);
|
ASSERT(oinfo != NULL);
|
||||||
|
|
||||||
|
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, fsbno)))
|
||||||
|
return -EFSCORRUPTED;
|
||||||
|
|
||||||
xefi = kmem_cache_zalloc(xfs_extfree_item_cache,
|
xefi = kmem_cache_zalloc(xfs_extfree_item_cache,
|
||||||
GFP_KERNEL | __GFP_NOFAIL);
|
GFP_KERNEL | __GFP_NOFAIL);
|
||||||
xefi->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
|
xefi->xefi_startblock = fsbno;
|
||||||
xefi->xefi_blockcount = 1;
|
xefi->xefi_blockcount = 1;
|
||||||
xefi->xefi_owner = oinfo->oi_owner;
|
xefi->xefi_owner = oinfo->oi_owner;
|
||||||
|
|
||||||
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, xefi->xefi_startblock)))
|
|
||||||
return -EFSCORRUPTED;
|
|
||||||
|
|
||||||
trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
|
trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
|
||||||
|
|
||||||
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &xefi->xefi_list);
|
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &xefi->xefi_list);
|
||||||
|
|||||||
Reference in New Issue
Block a user