Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5456550rwp; Mon, 17 Jul 2023 04:40:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlGPoTCFQXMhsFGcbXs/9j45WyokYzFFCGth8Sjpyw+XdFVL0SOfWjX14PBNFqGdlMtLpwg2 X-Received: by 2002:a17:902:7c04:b0:1ba:ff05:d8b1 with SMTP id x4-20020a1709027c0400b001baff05d8b1mr11776471pll.19.1689594019629; Mon, 17 Jul 2023 04:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689594019; cv=none; d=google.com; s=arc-20160816; b=EY/pKIjzAb1ZekSVhj7Ro4XZlNF6B6VyoxHaFMSzbrtfBbOB0eFyShpKmTLkvCK7pV dlaEpQEhKyhkazBnHyELkXqaKYwuKfiH/YKB9MbnzT9RZmBsafAoT7JqRgI3NSK2LvHh esqsyJXy2tcn3dlm1cheJ/A9W0yzV05DV+nJG6D0HPSP8t6PnP6BtxshCZBBacSCMZn3 7IH+WN56GstM4mBhSjZy/yIo5P2IsVtIe4r1m33iEgyvw5Hq1R8BOPaZ7cpxIykThANU u2umAwG5fvRCpencA70ESI/UDTZFbBjeIo9r55n8iOtq6983nG2+EEAdN82cPReejnQq QPXQ== 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=nyeBNbX2azWt1kI2Z9Fk+sv0QWQ4EEaGIjSHh7ZVxbA=; fh=EIWZp1cj2wwl8nxfYaWZLk2CKEAo1oYa6SeG5AIPFkU=; b=jwN+ZnCGMv+qVFaLyzCyI3p3rWYhI4W2S0YCzRgCrToAqyGh5Zjys0+JHLyp7AexSV +Ufu4mN6KmPFKoZn5AvtFdcdaRdVmRErEWyPpl099MN0m7y7DcT3vg45UFJoT9yO7gaA Q5vnibUDNrTdfSMoADqGur7YM4ojF9z3WGmCL5drbRoDrU+Hwza5NTEWJwZg/7gR0whB uwlY87s6L0OB5XuflTkDiDRVw4x9m1tBnR44FG0PNj5d118hvuIJ60xhcY+qWqVJAZSQ c0BHJUMwzkdIQ5bqoAw8K8Auin8CKgpryplu9ZBGRw+MOv2HGo/uImXygjlo4IJWVwIC MScQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902650500b001b8805f98e9si11588389plk.452.2023.07.17.04.40.07; Mon, 17 Jul 2023 04:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbjGQL1K (ORCPT + 99 others); Mon, 17 Jul 2023 07:27:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjGQL1J (ORCPT ); Mon, 17 Jul 2023 07:27:09 -0400 Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F6BE4C for ; Mon, 17 Jul 2023 04:27:07 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R961e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Vnc8ouu_1689593223; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0Vnc8ouu_1689593223) by smtp.aliyun-inc.com; Mon, 17 Jul 2023 19:27:04 +0800 From: Jingbo Xu To: hsiangkao@linux.alibaba.com, chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH v2] erofs: deprecate superblock checksum feature Date: Mon, 17 Jul 2023 19:27:03 +0800 Message-Id: <20230717112703.60130-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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-kernel@vger.kernel.org Later we're going to try the self-contained image verification. The current superblock checksum feature has quite limited functionality, instead, merkle trees can provide better protection for image integrity. xxhash is also used in the following xattr name filter feature. It is redundant for one filesystem to rely on two hashing algorithms at the same time. Since the superblock checksum is a compatible feature, just deprecate it now. Signed-off-by: Jingbo Xu --- changes since v1: - improve commit message (Gao Xiang) v1: https://lore.kernel.org/all/20230714033832.111740-1-jefflexu@linux.alibaba.com/ --- fs/erofs/Kconfig | 1 - fs/erofs/super.c | 44 +++++--------------------------------------- 2 files changed, 5 insertions(+), 40 deletions(-) diff --git a/fs/erofs/Kconfig b/fs/erofs/Kconfig index f259d92c9720..ebcb1f6a426a 100644 --- a/fs/erofs/Kconfig +++ b/fs/erofs/Kconfig @@ -4,7 +4,6 @@ config EROFS_FS tristate "EROFS filesystem support" depends on BLOCK select FS_IOMAP - select LIBCRC32C help EROFS (Enhanced Read-Only File System) is a lightweight read-only file system with modern designs (e.g. no buffer heads, inline diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 9d6a3c6158bd..bb6a966ac4d4 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -51,33 +50,6 @@ void _erofs_info(struct super_block *sb, const char *function, va_end(args); } -static int erofs_superblock_csum_verify(struct super_block *sb, void *sbdata) -{ - size_t len = 1 << EROFS_SB(sb)->blkszbits; - struct erofs_super_block *dsb; - u32 expected_crc, crc; - - if (len > EROFS_SUPER_OFFSET) - len -= EROFS_SUPER_OFFSET; - - dsb = kmemdup(sbdata + EROFS_SUPER_OFFSET, len, GFP_KERNEL); - if (!dsb) - return -ENOMEM; - - expected_crc = le32_to_cpu(dsb->checksum); - dsb->checksum = 0; - /* to allow for x86 boot sectors and other oddities. */ - crc = crc32c(~0, dsb, len); - kfree(dsb); - - if (crc != expected_crc) { - erofs_err(sb, "invalid checksum 0x%08x, 0x%08x expected", - crc, expected_crc); - return -EBADMSG; - } - return 0; -} - static void erofs_inode_init_once(void *ptr) { struct erofs_inode *vi = ptr; @@ -113,15 +85,16 @@ static void erofs_free_inode(struct inode *inode) static bool check_layout_compatibility(struct super_block *sb, struct erofs_super_block *dsb) { - const unsigned int feature = le32_to_cpu(dsb->feature_incompat); + struct erofs_sb_info *sbi = EROFS_SB(sb); - EROFS_SB(sb)->feature_incompat = feature; + sbi->feature_compat = le32_to_cpu(dsb->feature_compat); + sbi->feature_incompat = le32_to_cpu(dsb->feature_incompat); /* check if current kernel meets all mandatory requirements */ - if (feature & (~EROFS_ALL_FEATURE_INCOMPAT)) { + if (sbi->feature_incompat & (~EROFS_ALL_FEATURE_INCOMPAT)) { erofs_err(sb, "unidentified incompatible feature %x, please upgrade kernel version", - feature & ~EROFS_ALL_FEATURE_INCOMPAT); + sbi->feature_incompat & ~EROFS_ALL_FEATURE_INCOMPAT); return false; } return true; @@ -365,13 +338,6 @@ static int erofs_read_superblock(struct super_block *sb) goto out; } - sbi->feature_compat = le32_to_cpu(dsb->feature_compat); - if (erofs_sb_has_sb_chksum(sbi)) { - ret = erofs_superblock_csum_verify(sb, data); - if (ret) - goto out; - } - ret = -EINVAL; if (!check_layout_compatibility(sb, dsb)) goto out; -- 2.19.1.6.gb485710b