Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5697405rwd; Mon, 5 Jun 2023 07:23:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ibh5r+1ytKDSOe5+tlZmlFIwkvBTOAJcraY3wUGUqKcF1A6Jdp9qwLf5Ne121b5Y6Pgwb X-Received: by 2002:a17:902:b187:b0:1ab:2034:26da with SMTP id s7-20020a170902b18700b001ab203426damr6370560plr.51.1685974998940; Mon, 05 Jun 2023 07:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685974998; cv=none; d=google.com; s=arc-20160816; b=GJI9haY8y8nkeF2SPYRL8E5/4zsXRViVoCAdY3+MZ18SKZuJ8UqPCpbnBjhfDPFoGG o4jAvPcrTuj/8qXjG4w3QYov5BNuau9JZ26SOsXlu7I8S20QjJAXfjvHgtZIGuyhgmmR ymJ+bg/VZrb6zDiRRgpAtf8mDDw8BeRLzl/EBXR2qdbtAwoGX6mWJnXc5LoruL6TZRTk VXCNP9/iM8pmiGoiFTtmjrmEOJszeJ2NLKEbAtcw5MwjY1gfo8uFWRRbsCoGQ1WHqDWy nkc3ppSlUqAUL6QkNMsz3sgCqD0+LK3T8ZXSpEkgn3uGWLCtDJuHufBy1mWabibMDJaT yX/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mAC0mY+DBRqJMf8GuWWb4/XxRaAVTRi/YcpY/QiCxzw=; b=HER+VqEWag1XtDWqK9HNPin3zRn1UTEoX2OnbkQlWCCmuyfClbtv6aW7TrJmkXc5+G ztbea6ZGL3XmRq34kwpf+WLt29QnFDwhgRa7manjoCgLRrt6/CX7MV+//XH/Ydh0+rWo WeO8qL7zPEFDCjonKB/JDtwDS/WEcO2W006xxEIF3masMT/5+W5J6BuZYlCfYqIoMEAw 4MYjJ4esLDi5kicwGNIEOjgm8LCxkvS9CmsCVcTZmOpnMPN9lg24I3366ZlXrkaPZE/Q N1SESjDvd4j2shUTznUr84+z2Pgx+4pR4LP6y9ivMPQfq4fEyQnl2jQcK1VwcEd8sECz CqyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja12-20020a170902efcc00b001ae8b0f8491si5354377plb.454.2023.06.05.07.23.03; Mon, 05 Jun 2023 07:23:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbjFEOLz (ORCPT + 99 others); Mon, 5 Jun 2023 10:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234450AbjFEOLi (ORCPT ); Mon, 5 Jun 2023 10:11:38 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5539010C1 for ; Mon, 5 Jun 2023 07:10:08 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QZb682XN2zLm1k; Mon, 5 Jun 2023 22:07:44 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 5 Jun 2023 22:09:24 +0800 From: Ye Bin To: , CC: , Jan Kara , Subject: [PATCH v2 1/2] quota: Properly disable quotas when add_dquot_ref() fails Date: Mon, 5 Jun 2023 22:07:30 +0800 Message-ID: <20230605140731.2427629-2-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230605140731.2427629-1-yebin10@huawei.com> References: <20230605140731.2427629-1-yebin10@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara 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 --- 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 ffd40dc3e4e9..6beceed34e08 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.31.1