]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
quota: Properly disable quotas when add_dquot_ref() fails
authorJan Kara <jack@suse.cz>
Mon, 5 Jun 2023 14:07:30 +0000 (22:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Aug 2023 14:35:08 +0000 (16:35 +0200)
[ Upstream commit 6a4e3363792e30177cc3965697e34ddcea8b900b ]

When add_dquot_ref() fails (usually due to IO error or ENOMEM), we want
to disable quotas we are trying to enable. However dquot_disable() call
was passed just the flags we are enabling so in case flags ==
DQUOT_USAGE_ENABLED dquot_disable() call will just fail with EINVAL
instead of properly disabling quotas. Fix the problem by always passing
DQUOT_LIMITS_ENABLED | DQUOT_USAGE_ENABLED to dquot_disable() in this
case.

Reported-and-tested-by: Ye Bin <yebin10@huawei.com>
Reported-by: syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20230605140731.2427629-2-yebin10@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/quota/dquot.c

index 7c364cda8daac8e309a6d1c9d5a77763b516230f..1cbec5dde583014ac224ebb0174cce3caeabf7c4 100644 (file)
@@ -2387,7 +2387,8 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
 
        error = add_dquot_ref(sb, type);
        if (error)
-               dquot_disable(sb, type, flags);
+               dquot_disable(sb, type,
+                             DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
 
        return error;
 out_file_init: