Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3745BC4167B for ; Tue, 29 Nov 2022 07:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiK2HCp (ORCPT ); Tue, 29 Nov 2022 02:02:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbiK2HCn (ORCPT ); Tue, 29 Nov 2022 02:02:43 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE0B183A3 for ; Mon, 28 Nov 2022 23:02:42 -0800 (PST) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NLtVZ3M6KzJp1d; Tue, 29 Nov 2022 14:59:18 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 15:02:40 +0800 Received: from [10.174.178.112] (10.174.178.112) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 29 Nov 2022 15:02:40 +0800 Message-ID: Date: Tue, 29 Nov 2022 15:02:39 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0 Content-Language: en-US To: CC: , Zhiqiang Liu , , , "lijinlin (A)" From: "lihaoxiang (F)" Subject: [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.112] X-ClientProxiedBy: dggpeml100017.china.huawei.com (7.185.36.161) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In our knowledge, ext2fs_mmp_stop use to process the rest of work when mmp will finish. Critically, it must check if the mmp block is not changed. But there exist an error in comparing the mmp and mmp_cmp. Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the superblock of disk and it copy to mmp_buf if mmp_buf is not none and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop pass the no NULL pointer fs->mmp_buf which has possed the mmp info to ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf by fs->mmp_cmp so that loss the meaning of comparing themselves after that and worse yet, couldn't judge whether the struct of mmp has changed. In fact, we only need to modify the parameter to NULL pointer for solving this problem. Signed-off-by: lihaoxiang --- lib/ext2fs/mmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c index 7970aac2..14289706 100644 --- a/lib/ext2fs/mmp.c +++ b/lib/ext2fs/mmp.c @@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs) (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL)) goto mmp_error; - retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf); + retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL); if (retval) goto mmp_error; -- 2.37.0.windows.1