From patchwork Mon Jul 17 11:27:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 121221 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1052663vqt; Mon, 17 Jul 2023 04:40:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlFFrOGjBMKsW2A3sbB6sc9DFGWxTF8U9F3u0IIVxYTQV7vt1JDIx5Ln8LFe5D/pCBVVDJzR X-Received: by 2002:a05:6a20:42a9:b0:133:6219:15e2 with SMTP id o41-20020a056a2042a900b00133621915e2mr15316401pzj.21.1689594027858; Mon, 17 Jul 2023 04:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689594027; cv=none; d=google.com; s=arc-20160816; b=gT+IjI1hNd+hhyky/DTk7Dm+8LjK4AruJx2cVJOcAkg79fNl87n9M5Ar3s/IVanKn5 IlkeyUM/ge1qoYvUqyMe4vUQigUrubgL1il+ChrzTlh1l9E1/IbY7Xy8rNq1wTCHX4Pf Esvh5W2Rl39blkDlDoODqeGg/vnCVkNMMB5c/VgfAhfiagLjd0xSAUFXQ7qsI/gVbZhd 8ySTV3y+kLp1hkwROePbFJRqa1b5aAtXKZPGkg+ZsZVSpxwaCnig8OEUoHTxVoXseICW vM/a4p+myCA8pPM595K7YsCNTVbMq0B7LThVdX/AIh7NSXqWMc5povs7QngJLjPYfHQp Sr2A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 24-20020a631258000000b005579a12f405si11102237pgs.200.2023.07.17.04.40.14; Mon, 17 Jul 2023 04:40:27 -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 S229450AbjGQL1K (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771667747409825423 X-GMAIL-MSGID: 1771667747409825423 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 Reviewed-by: Gao Xiang Reviewed-by: Chao Yu --- 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;