提交 5b70c51a 编写于 作者: J Jan Kara 提交者: Zheng Zengkai

ext4: make sure to reset inode lockdep class when quota enabling fails

stable inclusion
from stable-v5.10.94
commit 762e4c33e9e5ecdcfedb1752e38c2aac2921df2e
bugzilla: https://gitee.com/openeuler/kernel/issues/I531X9

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

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

commit 4013d47a upstream.

When we succeed in enabling some quota type but fail to enable another
one with quota feature, we correctly disable all enabled quota types.
However we forget to reset i_data_sem lockdep class. When the inode gets
freed and reused, it will inherit this lockdep class (i_data_sem is
initialized only when a slab is created) and thus eventually lockdep
barfs about possible deadlocks.

Reported-and-tested-by: syzbot+3b6f9218b1301ddda3e2@syzkaller.appspotmail.com
Signed-off-by: NJan Kara <jack@suse.cz>
Cc: stable@kernel.org
Link: https://lore.kernel.org/r/20211007155336.12493-3-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 fe4a4f0a
...@@ -6524,8 +6524,19 @@ static int ext4_enable_quotas(struct super_block *sb) ...@@ -6524,8 +6524,19 @@ static int ext4_enable_quotas(struct super_block *sb)
"Failed to enable quota tracking " "Failed to enable quota tracking "
"(type=%d, err=%d). Please run " "(type=%d, err=%d). Please run "
"e2fsck to fix.", type, err); "e2fsck to fix.", type, err);
for (type--; type >= 0; type--) for (type--; type >= 0; type--) {
struct inode *inode;
inode = sb_dqopt(sb)->files[type];
if (inode)
inode = igrab(inode);
dquot_quota_off(sb, type); dquot_quota_off(sb, type);
if (inode) {
lockdep_set_quota_inode(inode,
I_DATA_SEM_NORMAL);
iput(inode);
}
}
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册