Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp304352pxj; Thu, 20 May 2021 09:41:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkuKgl58lXf/mYD+2Cwe0AvoVqhnKvxIaTe8OKb/gZM5+zKsszJeaGTeWE8LHQKvtQbcUw X-Received: by 2002:aa7:d94f:: with SMTP id l15mr6197395eds.235.1621528912393; Thu, 20 May 2021 09:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621528912; cv=none; d=google.com; s=arc-20160816; b=OOgV8tIzr8TZbKnPteQDNke4LEkdmwbWU3fFKClGrDEP80UZDsPPidtlqdskGgv6o/ rnt+pvuMcy/JbFVEsyoj0FhDV6t19W/Dmk3XdHwG1UY1OgJrlXyPmyET30AvfV5YArCE xj1Q/x9PPGzwiJ9x2eV/iQ2dScT3gPZCiq1rZQYzCW/IZr7GRavqm1Hq9DmThKc1xaYI Ic6bu/rDSuLKV41lk5Ab8z7fORJcVrKHh92ka4thTifqGSNQ1YTI+pkv2CJE5Yqe0nbM jyjMgoeA3GqZsPYB4q4TgDremhV264Hf79qzno93+RdV4h2CwnQoi0/B+h1GaPUtK4/C vHrA== 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=zzRxDZLf36rHs4HDvzJks7HXifycTGEreFNnodnK50U=; b=Ny5s+Wmgidam8fUxpAskel9J/NMe1qYTqTgDpyXXoqnQ/uoWhTrahR0YdjSM0a0Jqk 4E0nN+Jp9M9xuwTSOAGK9Lw8H5H0TcxmwXdwoWGpuO939NpyO5BdVdlH0c3FQkS04Rqh iLxa0+3mLpB4zBcHD1g2s8SpXM6Y+cjJimrEzXFq4zJ+AgHIAbDDv7E8JHuYR/VIbzZh 5LJLChOGmNuEpbfjgHbYqfjdNzehdckDuwhXTjkd0j7ANzsMiikTBdJQJgcOcXKnV4+l I0GyzVIBZCP2d1fKICOkXrXIqL9LYBXUK8Qkw6i6GOaTgsrYiBkCQGebYS6pMhxQoLKN HSSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YMzxnTa4; 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 bi14si2830540ejb.441.2021.05.20.09.41.28; Thu, 20 May 2021 09:41:52 -0700 (PDT) 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=YMzxnTa4; 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 S232974AbhETJrB (ORCPT + 99 others); Thu, 20 May 2021 05:47:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:47342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233572AbhETJn4 (ORCPT ); Thu, 20 May 2021 05:43:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C27561449; Thu, 20 May 2021 09:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503181; bh=6Kwn4qm0EImM8yJ9ziEGh5gMtsnjkfvAEhko4e9JXlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YMzxnTa4xxtCoDKRqc7DRCYzPK1liVFjRAuYe1GX4V3G6Vwpea9Oz7GniicFFWp3I PDJtFROy6elqVmJF+RHcGXZvxZAjCo9uj6zPjPXuYPoV18AdpEH1CPr3EGGl2n16wd S5kl4E0HIqma8vv8idziZ+1JxI9pRU69qr5pK6Co= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Zhang Yi , Jan Kara , Theodore Tso Subject: [PATCH 4.19 104/425] ext4: do not set SB_ACTIVE in ext4_orphan_cleanup() Date: Thu, 20 May 2021 11:17:53 +0200 Message-Id: <20210520092134.875871284@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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: Zhang Yi commit 72ffb49a7b623c92a37657eda7cc46a06d3e8398 upstream. When CONFIG_QUOTA is enabled, if we failed to mount the filesystem due to some error happens behind ext4_orphan_cleanup(), it will end up triggering a after free issue of super_block. The problem is that ext4_orphan_cleanup() will set SB_ACTIVE flag if CONFIG_QUOTA is enabled, after we cleanup the truncated inodes, the last iput() will put them into the lru list, and these inodes' pages may probably dirty and will be write back by the writeback thread, so it could be raced by freeing super_block in the error path of mount_bdev(). After check the setting of SB_ACTIVE flag in ext4_orphan_cleanup(), it was used to ensure updating the quota file properly, but evict inode and trash data immediately in the last iput does not affect the quotafile, so setting the SB_ACTIVE flag seems not required[1]. Fix this issue by just remove the SB_ACTIVE setting. [1] https://lore.kernel.org/linux-ext4/99cce8ca-e4a0-7301-840f-2ace67c551f3@huawei.com/T/#m04990cfbc4f44592421736b504afcc346b2a7c00 Cc: stable@kernel.org Signed-off-by: Zhang Yi Tested-by: Jan Kara Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20210331033138.918975-1-yi.zhang@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 3 --- 1 file changed, 3 deletions(-) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2629,9 +2629,6 @@ static void ext4_orphan_cleanup(struct s sb->s_flags &= ~SB_RDONLY; } #ifdef CONFIG_QUOTA - /* Needed for iput() to work correctly and not trash data */ - sb->s_flags |= SB_ACTIVE; - /* * Turn on quotas which were not enabled for read-only mounts if * filesystem has quota feature, so that they are updated correctly.