提交 9359c4a4 编写于 作者: J Jan Kara 提交者: Zheng Zengkai

ext4: make sure quota gets properly shutdown on error

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

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

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

commit 15fc69bb upstream.

When we hit an error when enabling quotas and setting inode flags, we do
not properly shutdown quota subsystem despite returning error from
Q_QUOTAON quotactl. This can lead to some odd situations like kernel
using quota file while it is still writeable for userspace. Make sure we
properly cleanup the quota subsystem in case of error.
Signed-off-by: NJan Kara <jack@suse.cz>
Cc: stable@kernel.org
Link: https://lore.kernel.org/r/20211007155336.12493-2-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>
上级 5b70c51a
...@@ -6438,10 +6438,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, ...@@ -6438,10 +6438,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA);
err = dquot_quota_on(sb, type, format_id, path); err = dquot_quota_on(sb, type, format_id, path);
if (err) { if (!err) {
lockdep_set_quota_inode(path->dentry->d_inode,
I_DATA_SEM_NORMAL);
} else {
struct inode *inode = d_inode(path->dentry); struct inode *inode = d_inode(path->dentry);
handle_t *handle; handle_t *handle;
...@@ -6461,7 +6458,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, ...@@ -6461,7 +6458,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
ext4_journal_stop(handle); ext4_journal_stop(handle);
unlock_inode: unlock_inode:
inode_unlock(inode); inode_unlock(inode);
if (err)
dquot_quota_off(sb, type);
} }
if (err)
lockdep_set_quota_inode(path->dentry->d_inode,
I_DATA_SEM_NORMAL);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册