Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2298842rdb; Sun, 3 Dec 2023 10:33:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbOUYB4h7GzV1ymZ43gBdKeF1KUq8tEDWDzgaLftqLydkFSuRcaC/NTxIkIMy7YdRix0z6 X-Received: by 2002:a05:6602:185a:b0:7b4:28f8:de with SMTP id d26-20020a056602185a00b007b428f800demr4020417ioi.39.1701628423766; Sun, 03 Dec 2023 10:33:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701628423; cv=none; d=google.com; s=arc-20160816; b=RurTHWxc7zYWrbaNMrtaSZnR5Z0QA30R2mN0EVMO/8uJNZm9Mj6BxZt6Rgtn64G46d mLExxJuAoGKZIucWkh6vmlCeMN+LQRtsvIUv7dXFh19pSvixL9MvvclzOaw2d1U2e9yS HVLgUMDn+QQiiDOl234XcBuK1kWyEhf0/Wm7VBrchTgRnPKz65GiOyEIrPZ7eDE6MShu 5t7Sa8PGtkjgy27lPadyOS0SaazJiGQVAENyA3uBV97SIJOivwU5q+JFEc7PyEiqqNx7 MTn+skMlvbl46xbPRAPZ+w0uLZ3T2BkwE9v0G7YJKPhWO7RTb8X5EJ8opKedqxFmQbOU xDyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=3KdTh7qu2wyEVz7mbvzfcC6qo4vY1PLBcIu+HyBe8cE=; fh=lu/tPeEXAWkOKkhDPjjju3elchBJBHmfBru6TOqAVzw=; b=FhV2tulqo4MDykL061EXz1E9XLCF3hd8ktaOcYUycht+osMvUratU8dnfdc36gvR7p hPEG1cIuVIzWwqSd+IpWnS1Fqt4757HENmi3K+pkmcr/3StRWwJ2Xk+zCTqDLWEAItht DaGZei7Kg7oD2jadJ/A/AVsyywImeGBapnFNs5BFPVLIv2PCVCIMchRPwOtZLuWTRff6 GZFkA8meCNV+hdPvHTp39qCE5O9jb+K4i5POXK0Z2WJ73W5HfDHpy11C8FWlq5QmoMOL YMERiQvoJhMOsZ7jHA6W5Mv79unX9cT8ftyD1XmiK41iW92BALJVnbVRzUQlcgf2B52J NXWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto+bounces-513-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u189-20020a6385c6000000b005c68df9b942si388701pgd.426.2023.12.03.10.33.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 10:33:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-513-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto+bounces-513-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6C71E280D6B for ; Sun, 3 Dec 2023 18:33:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32B151863F for ; Sun, 3 Dec 2023 18:33:43 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28363C8 for ; Sun, 3 Dec 2023 09:22:02 -0800 (PST) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VxgQUtK_1701624118; Received: from 30.27.123.200(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VxgQUtK_1701624118) by smtp.aliyun-inc.com; Mon, 04 Dec 2023 01:22:00 +0800 Message-ID: <649a3bc4-58bb-1dc8-85fb-a56e47b3d5c9@linux.alibaba.com> Date: Mon, 4 Dec 2023 01:21:58 +0800 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Weird EROFS data corruption To: Juhyung Park Cc: Gao Xiang , linux-erofs@lists.ozlabs.org, linux-f2fs-devel@lists.sourceforge.net, linux-crypto@vger.kernel.org, Yann Collet References: <5a0e8b44-6feb-b489-cdea-e3be3811804a@linux.alibaba.com> From: Gao Xiang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2023/12/4 01:01, Juhyung Park wrote: > Hi Gao, > > On Mon, Dec 4, 2023 at 1:52 AM Gao Xiang wrote: >> >> Hi Juhyung, >> >> On 2023/12/4 00:22, Juhyung Park wrote: >>> (Cc'ing f2fs and crypto as I've noticed something similar with f2fs a >>> while ago, which may mean that this is not specific to EROFS: >>> https://lore.kernel.org/all/CAD14+f2nBZtLfLC6CwNjgCOuRRRjwzttp3D3iK4Of+1EEjK+cw@mail.gmail.com/ >>> ) >>> >>> Hi. >>> >>> I'm encountering a very weird EROFS data corruption. >>> >>> I noticed when I build an EROFS image for AOSP development, the device >>> would randomly not boot from a certain build. >>> After inspecting the log, I noticed that a file got corrupted. >> >> Is it observed on your laptop (i7-1185G7), yes? or some other arm64 >> device? > > Yes, only on my laptop. The arm64 device seems fine. > The reason that it would not boot was that the host machine (my > laptop) was repacking the EROFS image wrongfully. > > The workflow is something like this: > Server-built EROFS AOSP image -> Image copied to laptop -> Laptop > mounts the EROFS image -> Copies the entire content to a scratch > directory (CORRUPT!) -> Changes some files -> mkfs.erofs > > So the device is not responsible for the corruption, the laptop is. Ok. > >> >>> >>> After adding a hash check during the build flow, I noticed that EROFS >>> would randomly read data wrong. >>> >>> I now have a reliable method of reproducing the issue, but here's the >>> funny/weird part: it's only happening on my laptop (i7-1185G7). This >>> is not happening with my 128 cores buildfarm machine (Threadripper >>> 3990X).> >>> I first suspected a hardware issue, but: >>> a. The laptop had its motherboard replaced recently (due to a failing >>> physical Type-C port). >>> b. The laptop passes memory test (memtest86). >>> c. This happens on all kernel versions from v5.4 to the latest v6.6 >>> including my personal custom builds and Canonical's official Ubuntu >>> kernels. >>> d. This happens on different host SSDs and file-system combinations. >>> e. This only happens on LZ4. LZ4HC doesn't trigger the issue. >>> f. This only happens when mounting the image natively by the kernel. >>> Using fuse with erofsfuse is fine. >> >> I think it's a weird issue with inplace decompression because you said >> it depends on the hardware. In addition, with your dataset sadly I >> cannot reproduce on my local server (Xeon(R) CPU E5-2682 v4). > > As I feared. Bummer :( > >> >> What is the difference between these two machines? just different CPU or >> they have some other difference like different compliers? > > I fully and exclusively control both devices, and the setup is almost the same. > Same Ubuntu version, kernel/compiler version. > > But as I said, on my laptop, the issue happens on kernels that someone > else (Canonical) built, so I don't think it matters. The only thing I could say is that the kernel side has optimized inplace decompression compared to fuse so that it will reuse the same buffer for decompression but with a safe margin (according to the current lz4 decompression implementation). It shouldn't behave different just due to different CPUs. Let me find more clues later, also maybe we should introduce a way for users to turn off this if needed. Thanks, Gao Xiang