提交 5606887f 编写于 作者: Z Zhihao Cheng 提交者: Yongqiang Liu

quota: Replace all block number checking with helper function

mainline inclusion
from mainline-v6.0-rc2
commit 3fc61e0e
category: bugfix
bugzilla: 187046, https://gitee.com/openeuler/kernel/issues/I5QH0X
CVE: NA

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

Cleanup all block checking places, replace them with helper function
do_check_range().

Link: https://lore.kernel.org/r/20220923134555.2623931-3-chengzhihao1@huawei.comSigned-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: NJan Kara <jack@suse.cz>
Signed-off-by: NZhong Jinghua <zhongjinghua@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 8b165737
...@@ -526,12 +526,10 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot, ...@@ -526,12 +526,10 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
goto out_buf; goto out_buf;
} }
newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
if (newblk < QT_TREEOFF || newblk >= info->dqi_blocks) { ret = do_check_range(dquot->dq_sb, "block", newblk, QT_TREEOFF,
quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)", info->dqi_blocks - 1);
newblk, info->dqi_blocks); if (ret)
ret = -EUCLEAN;
goto out_buf; goto out_buf;
}
if (depth == info->dqi_qtree_depth - 1) { if (depth == info->dqi_qtree_depth - 1) {
ret = free_dqentry(info, dquot, newblk); ret = free_dqentry(info, dquot, newblk);
...@@ -632,12 +630,10 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info, ...@@ -632,12 +630,10 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]); blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
if (!blk) /* No reference? */ if (!blk) /* No reference? */
goto out_buf; goto out_buf;
if (blk < QT_TREEOFF || blk >= info->dqi_blocks) { ret = do_check_range(dquot->dq_sb, "block", blk, QT_TREEOFF,
quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)", info->dqi_blocks - 1);
blk, info->dqi_blocks); if (ret)
ret = -EUCLEAN;
goto out_buf; goto out_buf;
}
if (depth < info->dqi_qtree_depth - 1) if (depth < info->dqi_qtree_depth - 1)
ret = find_tree_dqentry(info, dquot, blk, depth+1); ret = find_tree_dqentry(info, dquot, blk, depth+1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册