Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2697260pxj; Mon, 10 May 2021 08:45:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDmnYEkLcZ/koqX9uJRpwj6EbV0XZZyUyznZwtoshA2kB86MgYay/30LC2dn6rAHNuo5o5 X-Received: by 2002:a05:6e02:10c5:: with SMTP id s5mr23366864ilj.88.1620661554074; Mon, 10 May 2021 08:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620661554; cv=none; d=google.com; s=arc-20160816; b=Z52Ajn2iMZcB75rp6U6NfB2JGegPtLXMvV3Ncr2c5egS/TK3klEpLV/X7blXTz+rRQ ZgOouxPThbg2VCbrqeOyDXOsNU21eBGsvt1uYFjHOul4Adr0q5fTU4v2PBjG+XzdOfO2 t7J0s5AxizJvirQa2ppfwMP02w0GJKU1w+H0uXdURFMtWAx4YtQAxzrOSb9fAz4iF4f7 2LBnEfUUjeurZumAlZCvSOUiosbKZcFZEIcSvoEPOkvgurt3K+CGeUuoOlpxXBoH/qd1 TO4CZ5byK1RtGh4y2T7EsssehJXFI4nIgGt04LXFiM7zWuaXdJyojKNXq4OdYbPl9B5h By/A== 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=Gug2dMtxm1DZPNO5ol/whHZ2dfKRUx/zMHW8ddBDGv4=; b=LYrBRIMHrbogq1pkUaRChwQ7TcyaX71GDYOsSUu2KBL9V2+kB9vaCuq6h8GwG2PZ2B XnAvaSFHv9wUO/q2yClxyhyOwjBpdxVfiR8tELLao8Rv4HGaLLOrKwrkpiVgsv5zkv3r TVoRI7rKUqCCqdOn21HYx5kkYlNQzuf+ntCITYtwv7IpaLel03zPejd1UC1ZDoKC0fu8 /HTUs6meDgMPlm0bsByobRrtIa9YGaIHwNrk+or8AdJX4wBifq/eVbaaQt7/WLqmpNYD qXcgm3uxaPPmJTGl8fAO5/SfMCYnpKI32uD/l79HMz7wZ3bgx5gUhD1BEGZ5EWgqM9m6 suvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qVBXOAYw; 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 h16si17930370jaj.74.2021.05.10.08.45.41; Mon, 10 May 2021 08:45:54 -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=qVBXOAYw; 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 S238605AbhEJLSN (ORCPT + 99 others); Mon, 10 May 2021 07:18:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:41986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbhEJKya (ORCPT ); Mon, 10 May 2021 06:54:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5CFAB61A1D; Mon, 10 May 2021 10:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643322; bh=/auBXCiQiUTrRPsL+Ul0BZT87CtmFptG/SA6Mbp3XdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qVBXOAYwCdrPnisQ+lQxue35GCXR+rMuFcCN5NudX7s3rqWNPTF55+bbS0ZldC2UI IeIQt86QhDFAu7n2aLMPIAFMGw0+obbezc7NkLw0BSU4Yt4imKJhB85w5SE8BYn4mc 7f5P5IALf1vp4UxHKPRveDL5wypOddW2AH7TI0KI= 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.10 267/299] ext4: do not set SB_ACTIVE in ext4_orphan_cleanup() Date: Mon, 10 May 2021 12:21:04 +0200 Message-Id: <20210510102013.756047367@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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 @@ -3039,9 +3039,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.