Skip to content

Commit bd2c38c

Browse files
jankaratytso
authored andcommitted
ext4: Make sure quota files are not grabbed accidentally
If ext4 filesystem is corrupted so that quota files are linked from directory hirerarchy, bad things can happen. E.g. quota files can get corrupted or deleted. Make sure we are not grabbing quota file inodes when we expect normal inodes. Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b2bbb92 commit bd2c38c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/ext4/inode.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4603,6 +4603,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
46034603
struct ext4_iloc iloc;
46044604
struct ext4_inode *raw_inode;
46054605
struct ext4_inode_info *ei;
4606+
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
46064607
struct inode *inode;
46074608
journal_t *journal = EXT4_SB(sb)->s_journal;
46084609
long ret;
@@ -4613,9 +4614,12 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
46134614
projid_t i_projid;
46144615

46154616
if ((!(flags & EXT4_IGET_SPECIAL) &&
4616-
(ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)) ||
4617+
((ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO) ||
4618+
ino == le32_to_cpu(es->s_usr_quota_inum) ||
4619+
ino == le32_to_cpu(es->s_grp_quota_inum) ||
4620+
ino == le32_to_cpu(es->s_prj_quota_inum))) ||
46174621
(ino < EXT4_ROOT_INO) ||
4618-
(ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) {
4622+
(ino > le32_to_cpu(es->s_inodes_count))) {
46194623
if (flags & EXT4_IGET_HANDLE)
46204624
return ERR_PTR(-ESTALE);
46214625
__ext4_error(sb, function, line, false, EFSCORRUPTED, 0,

0 commit comments

Comments
 (0)