Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6557080rwb; Tue, 9 Aug 2022 18:30:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4c4tFEDQNxsfWH/Va/WoAqDGJYPUGUU+XpXRsmJ0mEirTRMkj6TFJbSFx8UZzq0vCGRVPS X-Received: by 2002:a17:906:8461:b0:730:a43a:9981 with SMTP id hx1-20020a170906846100b00730a43a9981mr18402373ejc.552.1660095041519; Tue, 09 Aug 2022 18:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660095041; cv=none; d=google.com; s=arc-20160816; b=JnvmDhCx+/ZoMPwBfIwilnu9dUWFd8Oa4UmUZCXUQ2lBqfJgImDCU03wlXZryWH/Gy Dc4GEnnITFOM1x8YHWyUhYhheuliJmDC6MWhtzcRS01+c5AGe/A8c1lH3FbErX/9gDWb I44PoRLdnnCbeW5rWtqFtW6hpygalrtwo8FyTT6ZNj2lsZU+3fBzAXgn4GlOfoboj+3B IXPUsxs9bA7aF9jUaiH8vy6klM6tXy070YzJAegt2JFCoOt9cSthb0oX5/MQrSAvfku4 3+f/+wc9z1Kxq1AFYYpCUGKkiXDtrXQZsVsW8iMJXhIN9iw4ZIr+7LAEgoOS/3efQl1K q4Uw== 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 :message-id:date:subject:cc:to:from; bh=DHJekJmDTDMVIgRfigDdvQD2yiZfaKtnMfTjM5mzqOA=; b=JINDGFZVopfRpV2a19ZSE8GtguWRL1K1Jy1MRkGNfgqq2JGK2xsoTnEzl2KhBD7Cnc XFDrcvrGJJun058ojky4NHFHXj8vByVJXtdgT2A5nfPwt5+Wdi3qzW8KV8ZJRn1fFqZt ktDD2qePZNmEl6OkzJxh2F8Iv7s/UDPShjv3Dzp57aFxDD5QoOyIaFPlQNRpADtN6oP2 vp6P0oFSf+cvsoLf3JnqBY08XYKn84OiFvnBLLJM29BfVJfrKxdqV8yvfZMTI9yGfHMp jEKhBulKO4fQNAo8Yo84CJZptQV1CieMql5za6X4veZa2dTOWKz2BA8P7xhfFsbE89Or BLtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc28-20020a1709078a1c00b0072b68ed1a49si3487412ejc.870.2022.08.09.18.30.07; Tue, 09 Aug 2022 18:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbiHJBW7 (ORCPT + 99 others); Tue, 9 Aug 2022 21:22:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiHJBW6 (ORCPT ); Tue, 9 Aug 2022 21:22:58 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33BB55C95F; Tue, 9 Aug 2022 18:22:57 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M2XBx4V4JzXdQw; Wed, 10 Aug 2022 09:18:49 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 10 Aug 2022 09:22:54 +0800 From: Ye Bin To: , , CC: , , Ye Bin Subject: [PATCH RFC] jbd2: detect old record when do journal scan Date: Wed, 10 Aug 2022 09:34:42 +0800 Message-ID: <20220810013442.3474533-1-yebin10@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org As https://github.com/tytso/e2fsprogs/issues/120 describe tune2fs do not update j_tail_sequence when do journal recovery. This maybe recover old journal record, then will lead to file system corruption. To avoid file system corruption in this case, if detect current transaction's commit time earlier than previous transaction's commit time when do journal scan, just return error. Signed-off-by: Ye Bin --- fs/jbd2/recovery.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index f548479615c6..f3def21a96a5 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -812,8 +812,17 @@ static int do_one_pass(journal_t *journal, break; } } - if (pass == PASS_SCAN) + if (pass == PASS_SCAN) { + if (commit_time < last_trans_commit_time) { + pr_err("JBD2: old journal record found " + "in transaction %u\n", + next_commit_ID); + err = -EFSBADCRC; + brelse(bh); + goto failed; + } last_trans_commit_time = commit_time; + } brelse(bh); next_commit_ID++; continue; -- 2.31.1