Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3470375rwb; Sun, 30 Jul 2023 08:16:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGyr/CrP/R4JfyaJDNmS+xrf9/1yvBUy7Avdw1LAVvwtEewDvoVECDi1790/bqeLgovlaI/ X-Received: by 2002:a17:90b:1a87:b0:262:c41e:1fcb with SMTP id ng7-20020a17090b1a8700b00262c41e1fcbmr8544568pjb.14.1690730216089; Sun, 30 Jul 2023 08:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690730216; cv=none; d=google.com; s=arc-20160816; b=rVvsrHyY0SMHN4ZMpRdbJWSgaWhPedGn97LfzSiPp6v75WVAXbl2/bSv2+QAIvsZA0 WWjtxIEtE/jvld832o231+O0M2ZLI4ONNEjpI0dg40MAVMl/OK093pbUyL+5CJaSzKfW sy6qzgAsrTJIqf8/f4hHBlXJVihX1beAA/zlH1aMS9kMbY6GBxR1rl7DmoPLQQCeu0Kh 2RkNe2OrsfNvBKA163bZ3oFuQ7I2J0w8g15NkLn+Y5EjEptTEOl1QRkHPadkWCzanAML trYGwpUPtUHce98fzXbGzBgguqiuFiyKyJYUaq8W/pSFMBkhXNttJLZ4BnX40kxTj+zL BN5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=JCECoQMofoErEINEAItFW09mW6FFFAgqg49cCk2i/jI=; fh=tYwJa1WUi+6bAp69wjabvYTSqrJSe4PvCs92dpiUCv0=; b=pJbZMp6eP6+hI5IhZkd4caAZ/mk/+tc1NjczYlucm6qtuccxmqlL0puG0QJQq7DB8o QQYdDHOjvT75rnqmXtOtOTcXV2iuaEiwx+YWaeTCzHUMiel/qJb9UteuDcHPRRMfWMht JWZCqJ5aSmfqZDKY5PgnVxqw0wMG/+K/RDWqbGzZr0TPzfeg6RfwJ4j+Ay6Rspksgo06 wFroUhUGYgvOdP5R/vrY/tN2LbmpIrAnJqp56tr1t2gQtSKRmKfRGEWJUjr90r3DFpJI bYcDp2XCcarTDzPzbDkaVxqoz/0SFBhqZZiu4bfSuMn7ZMIZcWrNnxdCyEPlHir5HiZf P2PQ== 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 il5-20020a17090b164500b00262f937bf93si6168117pjb.77.2023.07.30.08.16.43; Sun, 30 Jul 2023 08:16:56 -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 S229826AbjG3O43 (ORCPT + 99 others); Sun, 30 Jul 2023 10:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjG3O42 (ORCPT ); Sun, 30 Jul 2023 10:56:28 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4026170C for ; Sun, 30 Jul 2023 07:56:26 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R931e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VoW3cYo_1690728979; Received: from 30.27.65.211(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VoW3cYo_1690728979) by smtp.aliyun-inc.com; Sun, 30 Jul 2023 22:56:21 +0800 Message-ID: Date: Sun, 30 Jul 2023 22:56:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] erofs: deprecate superblock checksum feature To: =?UTF-8?Q?Thomas_Wei=c3=9fschuh?= Cc: Jingbo Xu , chao@kernel.org, huyue2@coolpad.com, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Karel Zak References: <20230717112703.60130-1-jefflexu@linux.alibaba.com> <9299dd4c-c2da-4ed1-8979-87fa44c68f77@t-8ch.de> <498e86f9-a7c3-4689-b277-319633a11789@t-8ch.de> From: Gao Xiang In-Reply-To: <498e86f9-a7c3-4689-b277-319633a11789@t-8ch.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,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 On 2023/7/30 22:49, Thomas Weißschuh wrote: > On 2023-07-30 22:37:19+0800, Gao Xiang wrote: >> On 2023/7/30 22:28, Thomas Weißschuh wrote: >>> On 2023-07-30 22:01:11+0800, Gao Xiang wrote: >>>> On 2023/7/30 21:31, Thomas Weißschuh wrote: >>>>> On 2023-07-17 19:27:03+0800, Jingbo Xu wrote: >>>>>> 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. >>>>> >>>>> The crc32c checksum is also used by libblkid to gain more confidence >>>>> in its filesystem detection. >>>>> I guess a merkle tree would be much harder to implement. >>>>> >>>>> This is for example used by the mount(8) cli program to allow mounting >>>>> of devices without explicitly needing to specify a filesystem. >>>>> >>>>> Note: libblkid tests for EROFS_FEATURE_SB_CSUM so at least it won't >>>>> break when the checksum is removed. >>> >>>> I'm not sure if we could switch EROFS_FEATURE_SB_CSUM to a simpler >>>> checksum instead (e.g. just sum each byte up if both >>>> EROFS_FEATURE_SB_CSUM and COMPAT_XATTR_FILTER bits are set, or >>>> ignore checksums completely at least in the kernel) if the better >>>> filesystem detection by using sb chksum is needed (not sure if other >>>> filesystems have sb chksum or just do magic comparsion)? >>> >>> Overloading EROFS_FEATURE_SB_CSUM in combination with >>> COMPAT_XATTR_FILTER would break all existing deployments of libblkid, so >>> it's not an option. >> >> I think for libblkid, you could still use: >> EROFS_FEATURE_SB_CSUM is not set, don't check anything; >> EROFS_FEATURE_SB_CSUM only is set, check with crc32c; >> EROFS_FEATURE_SB_CSUM | COMPAT_XATTR_FILTER (or some other bit) is >> set, check with a simpler hash? > > We could change this in newer versions of libblkid. > But we can't change the older versions that are already deployed today. > > And the current code does > > if (EROFS_FEATURE_SB_CSUM) > validate_crc32c(); > > So to stay compatible we need to keep the relationship of > EROFS_FEATURE_SB_CSUM -> crc32c. Yes, you are right, thanks for reminder. We really need a new bit for this. > >>> All other serious and halfway modern filesystems do have superblock >>> checksums which are also checked by libblkid. >>> >>>> The main problem here is after xattr name filter feature is added >>>> (xxhash is generally faster than crc32c), there could be two >>>> hard-depended hashing algorithms, this increases more dependency >>>> especially for embededed devices. >>> >>> From libblkid side nothing really speaks against a simpler checksum. >>> XOR is easy to implement and xxhash is already part of libblkid for >>> other filesystems. >>> >>> The drawbacks are: >>> * It would need a completely new feature bit in erofs. >>> * Old versions of libblkid could not validate checksums on newer >>> filesystems. >> >> just checking magic for Old versions of libblkid will cause false >> positive in which extent? > > Hard to tell for sure. But it would not surprise me if it would indeed > affect users as experience has shown. > > Imagine for example erofs filesystems that have then been overwritten > with another filesystem but still have a valid erofs magic. > With the checksum validation the new filesystem is detected correctly, > without it will find the old erofs. > > Sometimes the files inside some filesystem look like the superblock of > another filesystem and break the detection. > > etc. > > Having some sort of checksum makes this much easier to handle. Yes, but just checking magic for old versions of libblkid for new generated images only. I'm not sure about this all (I just suggest that we might need a simpler algorithm like XOR instead for sb_chksum otherwise it seems too heavy), let me just drop this commit from -next for further discussion. Thanks, Gao Xiang