Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3562839pxb; Mon, 24 Jan 2022 12:17:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyF55xUi7gXdLqpWUAalCZembwgUgzjfRlBEUQq5jEB080gm5i/sFEB4N85VzwKBeobNLfc X-Received: by 2002:a17:902:8204:b0:14b:550b:4ca3 with SMTP id x4-20020a170902820400b0014b550b4ca3mr5325543pln.139.1643055434915; Mon, 24 Jan 2022 12:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055434; cv=none; d=google.com; s=arc-20160816; b=vSqLO9qf7g6szTs7dGtkwHRmxzKTtR4dXQtrod8Ql6Lqx4TCvexkqEAlSSf0u5MlZE /YJ/ZtNA5V3OS2nbLx5YrYHjOcqtqsTSqW0iD+Dlq167DXNu6759FyJcaTayM5hQHseC xgcg0rrU+AhcNTEGHkiHrN+bOPUln+y3//PC6z2C0+jwRFc809c8aYuJdMXFloa4bTY4 8NiRANXzFxjoUG9WsjEcRTRSqow2gdRnYHjGQ8wpP0XPjN7k6DlMuPkQP2c+4e/MRk40 cOLAyeRmTqvd9TQrs/SiJiloqwKh+u+OE34ZDk48JYMz3DkxnFkzkzibVonCIUzlzxA8 K2ZQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iptaps1DN26QCzef6w6M/KH4T5lA/wuaikatAFJXyaQ=; b=fubFpMp5DBboUfP5ILGFUZreuykMqu6nmtsII9QSWT5nRkVhB7d9H9GZY4kSsfY+ri ONEMPGDFRH+FOoKyPy4tQLqelSozo4QJ0H3Etc9in5zurwvodMBAtCcS3XotarV9j2x5 rnDVtw1S2FI76nGJPnNtVH5VB/VNZOEbpEC5XqeUKMcrVx29DdT3IFdM76LBfulKKsw6 /OuRbIoi2apS/Vw7PGOiGPe7SDO9tZ3G+XO59BjNVs1Oudima57AHoxA32kN1L9UVRxR GF3ePg3OzaJiiB0Nb7CUnSYh6SifvxZhLA00r14MIiwZfM/zCuAJtrhXZo9d8XIeTDk6 8O6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1UGGe8Cx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 127si13654239pgc.257.2022.01.24.12.17.02; Mon, 24 Jan 2022 12:17:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1UGGe8Cx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236996AbiAXTTF (ORCPT + 99 others); Mon, 24 Jan 2022 14:19:05 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:38016 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347297AbiAXTKK (ORCPT ); Mon, 24 Jan 2022 14:10:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9D3E8611ED; Mon, 24 Jan 2022 19:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 659C9C340E7; Mon, 24 Jan 2022 19:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051409; bh=dvbrGGiVEQLOwzw10P90CvJsrbmFx1l9dlTRO+LfejY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1UGGe8Cx7DpN0gHdt1PssUtZFtZkLi/glcvFWxfASFfRDWS71VW4qlpdg6h+j/jLn UQdduWtaS+ne/z9oynyib5CLtlq7mBkqJApUnAIwzbIWbk97zV8RHdkCmnNriwPVCV iq9Pl1KUdwtaBuZSOO17cEpmDDiGRZhE3IcihzSQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , stable@kernel.org, Theodore Tso Subject: [PATCH 4.14 153/186] ext4: make sure quota gets properly shutdown on error Date: Mon, 24 Jan 2022 19:43:48 +0100 Message-Id: <20220124183942.024288543@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara commit 15fc69bbbbbc8c72e5f6cc4e1be0f51283c5448e upstream. When we hit an error when enabling quotas and setting inode flags, we do not properly shutdown quota subsystem despite returning error from Q_QUOTAON quotactl. This can lead to some odd situations like kernel using quota file while it is still writeable for userspace. Make sure we properly cleanup the quota subsystem in case of error. Signed-off-by: Jan Kara Cc: stable@kernel.org Link: https://lore.kernel.org/r/20211007155336.12493-2-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5678,10 +5678,7 @@ static int ext4_quota_on(struct super_bl lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); err = dquot_quota_on(sb, type, format_id, path); - if (err) { - lockdep_set_quota_inode(path->dentry->d_inode, - I_DATA_SEM_NORMAL); - } else { + if (!err) { struct inode *inode = d_inode(path->dentry); handle_t *handle; @@ -5701,7 +5698,12 @@ static int ext4_quota_on(struct super_bl ext4_journal_stop(handle); unlock_inode: inode_unlock(inode); + if (err) + dquot_quota_off(sb, type); } + if (err) + lockdep_set_quota_inode(path->dentry->d_inode, + I_DATA_SEM_NORMAL); return err; }