Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2554533pxj; Mon, 10 May 2021 05:49:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxntxBeL70g6RXyU2Sz02cO43IPTYCDlgAfDJiWHGOt6KWsRLnp/7N/mkzQMKkFleF9k2q5 X-Received: by 2002:a92:c78b:: with SMTP id c11mr21241106ilk.249.1620650984705; Mon, 10 May 2021 05:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620650984; cv=none; d=google.com; s=arc-20160816; b=rSyxc8+jYAQagALrRGqhPEzi9u4pqhy0cQqYxN37EwmH5yBmFBOQ6UHqGukih6+i3r wcDOAgYT0cwSdmGyhzmcwUK6FgF1Y53L43+2YCbeTJY+Yc7honS2HNgKeGKuCWmrUn5m rCmkuwgMY9/BOXsb0T8Vg4iefwA2bBxscSJnmv2HQe1e9LbFV2JjuXcQ+YYUgphkeUt4 9Xgi3Zt5wAkylpZZkWxfRl8Ov6fvdSz7g16tZbVqDYAoNipFNHlOeutgl0P/9arFrNxO Q62CUx+8NS5IfP+uN2uHmaKstVICEgE4k7eUA9MNkTgm18bKot3HratqmK1fN8rxfzAL VdRA== 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=9XKCZVOB0BFLZ1lPlSVmuoEWR7aSHpaQEAGowhA4Gd0=; b=fp1Wdtu0LtPHQutQO9hi62RkLq7pq6ULZ04WVV/4w3VkUqvHpaOmfBnxGV9iAFjs4/ jciDWoJG5reT/UCDcYrcNIflZJ/HSBBQlMuBp2rjZVcZc3ENzhUlJp3jsXhmnxRvN7rU l2mCZklR8fqXBP9urUoR51+qeXZ9FODzkFXWuQd/6ws1cRbyqUIqWNYSUekxfjQme5kR oMWDvbnksHXKu3DrnzGorS+u8G8tBZf1DPpdqw83ppRMZspSpxzzIlnXn8DbsHZ7RZEN EHViDEXnbisFjRa7IVneJtXSn89kX0MWS442EXD7GyRmRopfAxRZaxPPEGj0ui2g7PfB 3P6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OIMTUU0H; 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 j6si2794316ilr.104.2021.05.10.05.49.32; Mon, 10 May 2021 05:49:44 -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=OIMTUU0H; 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 S1347869AbhEJMhs (ORCPT + 99 others); Mon, 10 May 2021 08:37:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:55450 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237794AbhEJLQI (ORCPT ); Mon, 10 May 2021 07:16:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EF226147D; Mon, 10 May 2021 11:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620645086; bh=5fA5HRacLtdKHi/l2HsSrYgNzOh+9o/Td1vWYrbgJiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OIMTUU0Hp96PKsk+oOTRsoJApI0kKMQxTihAimsmpoAgSjpKUVqSe1svAm4Eoa1/w dCyMeLlpX9dO3K2Nl04C7ovEHwcaxJBLXm1oaod0+wMMjdW1WTkEsTOzxFiUbNiOzk Hy+4x+M6GlnbjGjxNJ87Z/rj+Q16lrRg6wXnysE8= 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.12 339/384] ext4: do not set SB_ACTIVE in ext4_orphan_cleanup() Date: Mon, 10 May 2021 12:22:08 +0200 Message-Id: <20210510102025.957090084@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102014.849075526@linuxfoundation.org> References: <20210510102014.849075526@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 @@ -3023,9 +3023,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.