From patchwork Mon Jun 5 14:07:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 103308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2736235vqr; Mon, 5 Jun 2023 07:46:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZhrCo3jnWkFA5P1lxzrVXKrnl6HadI0JUAD+7ZARimPkk0Jnoh+0BdhzlR12pmU2gB1m0 X-Received: by 2002:a05:6a00:198b:b0:650:d9c:cfca with SMTP id d11-20020a056a00198b00b006500d9ccfcamr20807444pfl.5.1685976365229; Mon, 05 Jun 2023 07:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685976365; cv=none; d=google.com; s=arc-20160816; b=Jm3DOuEpVRUf9jObZkoA3F3iAXC8g5L1VPNw8TTuEfG8VZTcYo+Yut0yZumf+DBObH PSTtUx59VDelqKnvKy8TI4NjCYJCacbttYF7MRTUEUo8d+FG6ddsBvoJo7gSsMxiip8B rvwkjkz34kNewz2t2EemqFvPYguqX9vOxSMpQIg+RgxVLiCn6BirZc6iYnqwnUEQhUUZ qDTNAoEV8dHpXxTahS0n++NilJyoFRHZeZBXsXqiKip7ejNPlQc7x49SfpOl5S+zuISh 3KDlQ4LS0hQX1vtaPy+xNMHaN72a84UosOtC7/Y3IkXZ6I7Y8hSU0MUPwjofPQ+KvuJo BFbQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a626d07000000b006414f237a50si5444943pfc.13.2023.06.05.07.45.51; Mon, 05 Jun 2023 07:46:05 -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 S234398AbjFEOLz (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767874353135867861?= X-GMAIL-MSGID: =?utf-8?q?1767874353135867861?= 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: