Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2468988pxj; Mon, 10 May 2021 03:51:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUlD2ZHbV8p8E7TURLMzdAc0fEy1DZMn28nSH9xJfabz4u2+UWnauFTQEtyRwV6lSaSy2j X-Received: by 2002:a92:1805:: with SMTP id 5mr20634283ily.82.1620643899194; Mon, 10 May 2021 03:51:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620643899; cv=none; d=google.com; s=arc-20160816; b=w/hmOlrw6Eq85TQTaJOjynrfi/yiRltxhP11p4mDDGSejeMshbySmq9H4biVfG5YWt vbaEbMgyWBHWpxIoub5Ku1rTcC0pKhV5MrWZSWBByxd/dY5ElV+kC8+JkzoJrwrEI1iN q9qCMvBm5k0YvYugVjlt2Z9CHv4NBau1ov9MVgEI8mqWqLhq4iJ91cdzUgsnjBa+9YpT P3cunqHbepeKEoXlI0XDIkW94L+Z6opRu3Y2+hqGENlf3z+h7uqVEhQ+kJ3Hgk4UvXcx VC3x79cGtbwGT5uBRJUC+llXsmWoNbotaxfJffflHlQD/B59CPAD2V649uHI8sPy1zpD yX5A== 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=Y2jF4QOhybARszVceEy2JsxoAAb063SjoWlGLh2dm8M=; b=y39+r+tiQvB2GW1IUicCxDOBoavpFylLHtE+z4kEuM3Og/f7HT04ooPnelTREqv2r+ 2p7iqvfMzZ03SEQ74+a/jtE6Cu/NsHIdlHNty5+EfSZMPFvBhVUF440eOwXyMu2Eg2TI QTIpWpylXBqKL5EFnCgxQ+K422jWsc4m6nSvkcd5wh4Y2UUSrV1h6Ld4CJcJjk7lMDjD qVOHxnvrMaHR3bLfiSwYD9rwpEMi+tUQnzuMs34Em2r3jjAn787LJcstiQUDXS8ltZv6 GE1QoHvrh5RLoNacN0hpb3qXqtd0PGjtYJaKDElZetUXkO2h1FdQNdTiWact5bOegzm4 Ay7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wCCp8dMT; 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 s18si16509636ilh.102.2021.05.10.03.51.27; Mon, 10 May 2021 03:51:39 -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=wCCp8dMT; 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 S233266AbhEJKty (ORCPT + 99 others); Mon, 10 May 2021 06:49:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:50354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbhEJKkl (ORCPT ); Mon, 10 May 2021 06:40:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68F3A61964; Mon, 10 May 2021 10:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642667; bh=AERqpN5kleDe6IwFjMQe4lw55vjyM8uwmiBMCBR9VjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wCCp8dMTDEOw4+ClDuSEphd8xwNjwqX498dVUdmI0WNF3j4oLzqzyaU4JnTEcjysy UVX2K0zUPsJ7F5OBOLH+OvyhXgu4GwXSK9JbsLaCZYv3y1wqM3hXhuxNKMUSh3F3a+ xeS6l7yEbB0r6dNy6td80Lul0H86YEOK95MDCLIE= 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 5.4 164/184] ext4: do not set SB_ACTIVE in ext4_orphan_cleanup() Date: Mon, 10 May 2021 12:20:58 +0200 Message-Id: <20210510101955.483965393@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510101950.200777181@linuxfoundation.org> References: <20210510101950.200777181@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 @@ -2675,9 +2675,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.