Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1588338ybv; Thu, 20 Feb 2020 23:49:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxXXJbGJH4t6XmBaZfim085lk1SQqfoSI8GWIIA4lA5T5fLmeCUcHTyHpUNWCm76+orsjzj X-Received: by 2002:a9d:6e98:: with SMTP id a24mr25977722otr.53.1582271398591; Thu, 20 Feb 2020 23:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271398; cv=none; d=google.com; s=arc-20160816; b=XB4yjqJtC1A+Cdaf8uqmX1S2PPLVFb0XrKhr+xPy3GByfQ62OfJrdZIf3luVB2Gdzl w5K43vIvYsuGdCqEfsvfwi3G5E3IKzUDd4xLKni3/X1ryLDNua7YNH2ZLLvjN4mUJxXl pAtaFaNXFUJyv9Xb9+lwaRd8CWotdzBP7FdRgFU57+yGD2F2seMHhWfwI/00wfqSvuls lgZjDIpauc0T6jEDOQZmbXVCHKW7OrzKZWyE8EUn3XanU0q/3aAqv1rkEH9zJNhXhF81 s/t918ulx0n2tdMtmucFc/YkJ7N8JHhWcj15XuBVaeErGJPAGsEORVqBG3QD6YEsTDXt ITSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Kpiyi9s3OBJ26XfwEGJ4lfc8AFDSWf3DCe5ftmfjZ0k=; b=Z6xzYKOSLlwwOP6VYRNsvsqIt4drtD/i7CwsRsHLsbiV+2suKIrsgH9QTCrX//mAvX LkJdBRCiqGNsGrcncr25zSxVQdXGN65VIOXZ8u4u3wnjCBKw9/rGgmN+koWQAs8DpuaF hKB/4CkmtX7QeEngUaLvAkl779NNyjptUV+ozbxjD/momVrdTtR+kul+cGkN4ovE6zcT qJogM4Fdqgi5kOpZ4M1IdWXd/H/A43lvzedhEQMwpYOSxkBywCYDSiAPGY+hi2VrgEgz s5e66yA8L5SlzE547ffjZJ4mCrwNPq46RjxueNDoHu0e+3SbLLRNAp2JwaxP80Dy0eMs 0nNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cyvov6A5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si1071217otk.321.2020.02.20.23.49.46; Thu, 20 Feb 2020 23:49:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cyvov6A5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728857AbgBUHsg (ORCPT + 99 others); Fri, 21 Feb 2020 02:48:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:44642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729106AbgBUHsd (ORCPT ); Fri, 21 Feb 2020 02:48:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34079207FD; Fri, 21 Feb 2020 07:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271312; bh=TtegpNH+Zsy5/vubfjs0atrWIbnFSMhn0zVsYmPVbHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cyvov6A51vYXbxI/dFRRnBbii9q4IdJXfqbpPoo5n8fZ/xLCUIQKTlvRZR+auaJ1w R2aKo85zkUjRHO+JddVx4EbpYaLc3+yXd5huptlktQL27SA74zbCc5rr8V8WlG+QoF upIt3oUp3AMjwN6gFkfRcP7FiHICJmkDmSsoQKy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Li , Theodore Tso , Sasha Levin Subject: [PATCH 5.5 071/399] jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal Date: Fri, 21 Feb 2020 08:36:36 +0100 Message-Id: <20200221072409.253370687@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai Li [ Upstream commit a09decff5c32060639a685581c380f51b14e1fc2 ] If the journal is dirty when the filesystem is mounted, jbd2 will replay the journal but the journal superblock will not be updated by journal_reset() because JBD2_ABORT flag is still set (it was set in journal_init_common()). This is problematic because when a new transaction is then committed, it will be recorded in block 1 (journal->j_tail was set to 1 in journal_reset()). If unclean shutdown happens again before the journal superblock is updated, the new recorded transaction will not be replayed during the next mount (because of stale sb->s_start and sb->s_sequence values) which can lead to filesystem corruption. Fixes: 85e0c4e89c1b ("jbd2: if the journal is aborted then don't allow update of the log tail") Signed-off-by: Kai Li Link: https://lore.kernel.org/r/20200111022542.5008-1-li.kai4@h3c.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/jbd2/journal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index b3e2433f94fe2..6847b18455068 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -1711,6 +1711,11 @@ int jbd2_journal_load(journal_t *journal) journal->j_devname); return -EFSCORRUPTED; } + /* + * clear JBD2_ABORT flag initialized in journal_init_common + * here to update log tail information with the newest seq. + */ + journal->j_flags &= ~JBD2_ABORT; /* OK, we've finished with the dynamic journal bits: * reinitialise the dynamic contents of the superblock in memory @@ -1718,7 +1723,6 @@ int jbd2_journal_load(journal_t *journal) if (journal_reset(journal)) goto recovery_error; - journal->j_flags &= ~JBD2_ABORT; journal->j_flags |= JBD2_LOADED; return 0; -- 2.20.1