aboutsummaryrefslogtreecommitdiffstats
path: root/fs/quota
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2021-11-06 16:40:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2021-11-06 16:40:48 -0700
commitd8b4e5bd4889e6568e8c3db983b4320f06091594 (patch)
treeeead3597abe6cc4ebfbef4e8c90b535144ae3b74 /fs/quota
parentMerge tag 'xtensa-20211105' of git://github.com/jcmvbkbc/linux-xtensa (diff)
parentfs: reiserfs: remove useless new_opts in reiserfs_remount (diff)
downloadlinux-dev-d8b4e5bd4889e6568e8c3db983b4320f06091594.tar.xz
linux-dev-d8b4e5bd4889e6568e8c3db983b4320f06091594.zip
Merge tag 'fs_for_v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull quota, isofs, and reiserfs updates from Jan Kara: "Fixes for handling of corrupted quota files, fix for handling of corrupted isofs filesystem, and a small cleanup for reiserfs" * tag 'fs_for_v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: fs: reiserfs: remove useless new_opts in reiserfs_remount isofs: Fix out of bound access for corrupted isofs image quota: correct error number in free_dqentry() quota: check block number when reading the block in quota file
Diffstat (limited to 'fs/quota')
-rw-r--r--fs/quota/quota_tree.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
index d3e995e1046f..5f2405994280 100644
--- a/fs/quota/quota_tree.c
+++ b/fs/quota/quota_tree.c
@@ -414,6 +414,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
quota_error(dquot->dq_sb, "Quota structure has offset to "
"other block (%u) than it should (%u)", blk,
(uint)(dquot->dq_off >> info->dqi_blocksize_bits));
+ ret = -EIO;
goto out_buf;
}
ret = read_blk(info, blk, buf);
@@ -479,6 +480,13 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
goto out_buf;
}
newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
+ if (newblk < QT_TREEOFF || newblk >= info->dqi_blocks) {
+ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
+ newblk, info->dqi_blocks);
+ ret = -EUCLEAN;
+ goto out_buf;
+ }
+
if (depth == info->dqi_qtree_depth - 1) {
ret = free_dqentry(info, dquot, newblk);
newblk = 0;
@@ -578,6 +586,13 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
if (!blk) /* No reference? */
goto out_buf;
+ if (blk < QT_TREEOFF || blk >= info->dqi_blocks) {
+ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
+ blk, info->dqi_blocks);
+ ret = -EUCLEAN;
+ goto out_buf;
+ }
+
if (depth < info->dqi_qtree_depth - 1)
ret = find_tree_dqentry(info, dquot, blk, depth+1);
else