From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E4D9C001DC for ; Mon, 24 Jul 2023 01:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbjGXBYM (ORCPT ); Sun, 23 Jul 2023 21:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbjGXBXL (ORCPT ); Sun, 23 Jul 2023 21:23:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFADEBF; Sun, 23 Jul 2023 18:22:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7573660F1B; Mon, 24 Jul 2023 01:22:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27FC3C433CB; Mon, 24 Jul 2023 01:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690161742; bh=X6b4b8eZK1Ioz2HYXhc0qpRBnXTtrtIGRkjYICqVhig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rTK43B+9eQ7sAz7vVPZLdfHyYhivxIUTQ9HZt11YTXe4+7GHJ8fDpgpe8PMwF1B/i G2aQSQTiQGNy0HyyV5b/08D0c9bxnks/nuE3/jvpZfixtLKGs8ScNcvkT5RGouVSNI M5IDXxAfgF2M3LEFc2dcLAyAzNiSCNTF9X6gZjSbb/2cATohG6osyMt0+jZNZEFoiO 8TfPzh/9q4dxvCzRR6hOUHxqNaqKDeSdWO5bBkqgsX093Cn7GcgkdhGE0LFHa6k6Eu BcnerwunxXzOmAM3qoTftB6UHHAMeAbVqn+Gj1ohSeZTOQYsSYeKi4oRSe/7N5gXNN 5jpLB108iCfxA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jan Kara , Ye Bin , syzbot+e633c79ceaecbf479854@syzkaller.appspotmail.com, Sasha Levin , jack@suse.com Subject: [PATCH AUTOSEL 6.1 18/41] quota: Properly disable quotas when add_dquot_ref() fails Date: Sun, 23 Jul 2023 21:20:51 -0400 Message-Id: <20230724012118.2316073-18-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230724012118.2316073-1-sashal@kernel.org> References: <20230724012118.2316073-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.40 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 f27faf5db5544..8181adcddf0d8 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2420,7 +2420,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.39.2