提交 f59848da 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

xfs: detect overflows in bmbt records

stable inclusion
from stable-v5.10.120
commit f20e67b455e425a0d3d03f27bda5fdd32dc2c324
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BR

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f20e67b455e425a0d3d03f27bda5fdd32dc2c324

--------------------------------

commit acf104c2 upstream.

Detect file block mappings with a blockcount that's either so large that
integer overflows occur or are zero, because neither are valid in the
filesystem.  Worse yet, attempting directory modifications causes the
iext code to trip over the bmbt key handling and takes the filesystem
down.  We can fix most of this by preventing the bad metadata from
entering the incore structures in the first place.

Found by setting blockcount=0 in a directory data fork mapping and
watching the fireworks.
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NAmir Goldstein <amir73il@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 bd05433c
...@@ -6206,6 +6206,11 @@ xfs_bmap_validate_extent( ...@@ -6206,6 +6206,11 @@ xfs_bmap_validate_extent(
xfs_fsblock_t endfsb; xfs_fsblock_t endfsb;
bool isrt; bool isrt;
if (irec->br_startblock + irec->br_blockcount <= irec->br_startblock)
return __this_address;
if (irec->br_startoff + irec->br_blockcount <= irec->br_startoff)
return __this_address;
isrt = XFS_IS_REALTIME_INODE(ip); isrt = XFS_IS_REALTIME_INODE(ip);
endfsb = irec->br_startblock + irec->br_blockcount - 1; endfsb = irec->br_startblock + irec->br_blockcount - 1;
if (isrt && whichfork == XFS_DATA_FORK) { if (isrt && whichfork == XFS_DATA_FORK) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册