From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55FE911C83 for ; Mon, 28 Aug 2023 10:36:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C72C0C433C7; Mon, 28 Aug 2023 10:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693218998; bh=sAQc3coW9oY28dBjlrh/yXtmj2CB2yIziMP7bBlL1Ds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yyza6BLZ4iyQL4eVacc/ZvsqseVWVUhtWR9jFf5si9Cy2hjRGN91pjeKQhpnFI8nG kbsqitgu2wq5TBtR3/J2c4nG0pgk4U+zfPFf4V+PSY0KwjWPDKfWAQfphXXFSh1Qrl oQXhz3oAuHVHWDC2V4GcQ5s5mPK2n7q8BLc/x/KE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com, Jan Kara , Sasha Levin , Ye Bin Subject: [PATCH 5.4 008/158] quota: Properly disable quotas when add_dquot_ref() fails Date: Mon, 28 Aug 2023 12:11:45 +0200 Message-ID: <20230828101157.604396864@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101157.322319621@linuxfoundation.org> References: <20230828101157.322319621@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ 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 Reported-by: syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com Signed-off-by: Jan Kara Message-Id: <20230605140731.2427629-2-yebin10@huawei.com> Signed-off-by: Sasha Levin --- fs/quota/dquot.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 1d652af48f0b1..44175f37bfeb5 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2415,7 +2415,8 @@ int dquot_load_quota_sb(struct super_block *sb, 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_fmt: -- 2.40.1