Skip to content
Snippets Groups Projects
Commit 863c8295 authored by Jan Kara's avatar Jan Kara Committed by Cheng Jian
Browse files

quota: Sanity-check quota file headers on load


mainline inclusion
from mainline-5.11-rc1
commit 11c514a99bb960941535134f0587102855e8ddee
category: bugfix
bugzilla: 49668
CVE: NA

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

Perform basic sanity checks of quota headers to avoid kernel crashes on
corrupted quota files.

CC: stable@vger.kernel.org
Reported-by: default avatar <syzbot+f816042a7ae2225f25ba@syzkaller.appspotmail.com>
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
parent 9b7f020c
No related branches found
No related tags found
No related merge requests found
......@@ -158,6 +158,25 @@ static int v2_read_file_info(struct super_block *sb, int type)
qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
qinfo->dqi_ops = &v2r1_qtree_ops;
}
ret = -EUCLEAN;
/* Some sanity checks of the read headers... */
if ((loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits >
i_size_read(sb_dqopt(sb)->files[type])) {
quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).",
(loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits,
i_size_read(sb_dqopt(sb)->files[type]));
goto out;
}
if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) {
quota_error(sb, "Free block number too big (%u >= %u).",
qinfo->dqi_free_blk, qinfo->dqi_blocks);
goto out;
}
if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) {
quota_error(sb, "Block with free entry too big (%u >= %u).",
qinfo->dqi_free_entry, qinfo->dqi_blocks);
goto out;
}
ret = 0;
out:
up_read(&dqopt->dqio_sem);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment