From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 934AC1DE894 for ; Sun, 26 Apr 2026 11:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777203773; cv=none; b=cBM4PAgE6OFZGS0UBSXCEquXuxbbblEnF+PckHYvM+sutnU86Fbedrt0KzjR9TpVNJcAjQ1wYKkbo2hF1mEhN+ieEX01Tt8f45XsIDJOcQURvfEOhdgsPOmsgb261jqTmmQybhBcf6XvWlycAeNP3TsS8rXSHgaWnCm7SJl3DmA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777203773; c=relaxed/simple; bh=kJxA9oClLHaU4OEVokkYdI+IHWTqJIbJUMk0XR0I/D8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Hm0w34MxUOQo+SkzUmtjb0I0X3MbyKxO58YKDiP3Y0cyBhxpLJ5hfAdGpCtTgcp6Un9unGqjkd1vQGHN3pw9B1MR/yKRigFNfU5JNHwOnxYUhe/zEns34DEUmc70feygsJJ1Fuw4sZGzWuL2LT4N4y1ORSGOC2o4Y0hq95tnSNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Or/I6vHI; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Or/I6vHI" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-38e84ed22bdso88211251fa.2 for ; Sun, 26 Apr 2026 04:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777203770; x=1777808570; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kJxA9oClLHaU4OEVokkYdI+IHWTqJIbJUMk0XR0I/D8=; b=Or/I6vHIoGHy3KN2/EMjLGS+PjVY5MAsd25Ssx1VnpwyoCJkRpgyZ+rMazwqgAIlee i2VvzayzWLOe1+jsJTArWvWhQKLBrsGhqhcRmlj080n5z8cGkYzExJ/mdSqS2EjbLl4K dlv4HkPx1WSOlAfhEW6SkbJsNdOb9LV4HGdm2hb4hoFw2k3MyXGLCvzkAkLufW8ERHeV BUarWSWOJxlKK8B2KXk0IBLGonuEpLt73DauzMLc8GLIECi+WqUqZWen1jyD0vT5/vwZ Y1gnwV15HgunBL4T+96P+ouDxwaRU/uued6s5DXTrXCiPQWdT21w1qP8unssCseAfbli s2kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777203770; x=1777808570; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kJxA9oClLHaU4OEVokkYdI+IHWTqJIbJUMk0XR0I/D8=; b=fSbrC0hVLzGKtNHHciaqMFvAJaq5KMmNoCw0VxoFBWbHG8xnCCiF3Xe68qtDWY9Gdv HFNsSOATSs4K5iEX5F08Qxf5gU5WwmihxTQ2iS5Xi3ad7CgjdQKcqosouog6VMY77ZuY 499pRIvMFDxCQJ0YUqlQ+Ba6sNy4JGVhgZLaE7ExqYj/sew5CoBaJlvDrlq56cgqHuLw tVmdmLgN6QubS/IDLleOu2w/bH3gM5F29KUsyt3DxlyzctlBf+uoHelDS0wLinF6q9xI dT+K6miUG+DXUYCSa702zGG3yfE8BYDzY3jt8PrqTnWn+LfwD4J1UsYxXYJPi/suZ8xh 1h1Q== X-Forwarded-Encrypted: i=1; AFNElJ8jpq1lNpaM2daeblVyLPR7YEAvCPQ+vHi6UmthDZoKTGm30ZsIcIM9xW8dvypQy9d5Ezg134rgOs2N7r0=@vger.kernel.org X-Gm-Message-State: AOJu0YzKrBOL2BlwSDsPdu7YpvCz0CF9lzOU5raoUHfzkqGmxjR4Qu+L oafJJwzkfJtosHa0qwfh/ryWHrnQn5rNXK5V8Q+Ul/kCuIsQ+AkCzwi8lcuizg== X-Gm-Gg: AeBDieukYyNNyss+Z977AMRckwe++fgWUPRWysSr/3K0I27fR3agNPeUzphVs5vHDvO 7sYx3nfQVh8mGlOIG3K7c5AoFH0T0Vz8iD/3YNuaHegsH7b9KlJZjxSZozt63Xt5nqITudOOcmr SP+Tn2VBKR0ETs5rYPxrT7oXezk501B40KmKgQncC8CujJYkjVnYku5QGdRdT0uuWEphMwWW0I4 KrW+4ZgXDil6jP8qpmB23KTun4FN/TI+chcCHZXyCf4M6ya4XTsiHq7YHd9rEJetH+X9zLBefF3 c6IdUgq973XQ9qNJEVSsiR0N/cm144UnDIoYMk30oWg49w8dtbOgUS+rmvpzPnVhJgWLS6S6tZA 1/n4VV9KBq8qwtW2Gy+MTfoiK77Ifz4LDRzIT48nfW19qhzDNlwze2wHhcC1Oxjci+EsRtrLpYU yfquqk6UXHIauT7vSVwUPUu2V/JPJbwj+Pjhrd8w== X-Received: by 2002:a05:651c:211f:b0:38e:ae31:f0ae with SMTP id 38308e7fff4ca-38ec745e678mr121731091fa.0.1777203769354; Sun, 26 Apr 2026 04:42:49 -0700 (PDT) Received: from [192.168.0.111] ([77.220.140.242]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb5f65absm60034281fa.11.2026.04.26.04.42.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Apr 2026 04:42:48 -0700 (PDT) Message-ID: Date: Sun, 26 Apr 2026 14:42:47 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: erofs pointer corruption and kernel crash Content-Language: ru To: Gao Xiang , Arseniy Krasnov Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel@salutedevices.com, Gao Xiang References: <4a2f3801-fac1-42fe-ae75-da315822e088@salutedevices.com> <2e916997-0557-45e7-831a-b436c07c5ba4@salutedevices.com> <97ca00c7-822d-4b57-9dc0-9b396049adc9@salutedevices.com> <8c0bdfab-dbf2-4f1e-8e2a-ce18f166d841@linux.alibaba.com> <2ca3c8c6-f3ed-40ca-8f5c-1b43df479ad7@salutedevices.com> <36cddf44-3e08-4a19-82ed-04ca178ffab5@linux.alibaba.com> <15702a84-ea4f-4d12-b9e5-a37a4c3bb014@salutedevices.com> From: Arseniy Krasnov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 25.04.2026 18:29, Gao Xiang пишет: > Hi Arseniy, > > On 2026/4/13 15:20, Arseniy Krasnov wrote: >> >> >> 13.04.2026 10:08, Gao Xiang пишет: >>> >>> >>> On 2026/4/11 23:10, Arseniy Krasnov wrote: >>>> >>>> >>>> 10.04.2026 18:41, Gao Xiang пишет: >>>>> Hi Arseniy, >>>>> >>>>> On 2026/4/10 21:27, Arseniy Krasnov wrote: >>>>>> >>>>>> >>>>>> 10.04.2026 15:20, Gao Xiang пишет: >>>>>>> >>>>>>> >>>>>>> On 2026/4/10 19:37, Arseniy Krasnov wrote: >>>>>>> >>>>>>> (drop unrelated folks since they all subscribed erofs mailing list) >>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> 10.04.2026 11:31, Gao Xiang wrote: >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> On 2026/4/10 16:13, Arseniy Krasnov wrote: >>> >>> ... >>> >>>>>>>>> >>>>>>>>> I need more informations to find some clues. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> So reproduced again with this debug patch which adds magic to 'struct z_erofs_pcluster' and prints 'struct folio' >>>>>>>> when pointer in 'private' is passed to 'erofs_onlinefolio_end()'. In short - 'private' points to 'struct z_erofs_pcluster'. >>>>>>> First, erofs-utils 1.8.10 doesn't support `-E48bit`: >>>>>>> only erofs-utils 1.9+ ship it as an experimental >>>>>>> feature, see Changelog; so I think you're using >>>>>>> modified erofs-utils 1.8.10: >>>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/tree/ChangeLog >>>>>>> >>>>>>> ``` >>>>>>> erofs-utils 1.9 >>>>>>> >>>>>>>     * This release includes the following updates: >>>>>>>       - Add 48-bit layout support for larger filesystems (EXPERIMENTAL); >>>>>>> ``` >>>>>>> >>>>>>> Second, I'm pretty sure this issue is related to >>>>>>> experimenal `-E48bit`, and those information is >>>>>>> not enough for me to find the root cause, so I >>>>>>> need to find a way to reproduce myself: It may >>>>>>> take time; you could debug yourself but I don't >>>>>>> think it's an easy task if you don't quite familiar >>>>>>> with the EROFS codebase. >>>>>>> >>>>>>> Anyway I really suggest if you need a rush solution >>>>>>> for production, don't use `-E48bit + zstd` like >>>>>>> this for now: try to use other options like >>>>>>> `-zzstd -C65536 -Efragments` instead since those >>>>>>> are common production choices. >>>>>> >>>>>> Ok thanks for this advice! One more question: currently we use this options: >>>>>> "zstd,22 --max-extent-bytes 65536 -E48bit". Ok we remove "zstd,22" and "E48bit", >>>>>> but what about "--max-extent-bytes 65536" - is it considered stable option? >>>>>> Or it is better to use your version: "-zzstd -C65536 -Efragments" ? >>>>> >>>>> I'm not sure how you find this >>>>> "zstd,22 --max-extent-bytes 65536 -E48bit" combination. >>>>> >>>>> My suggestion based on production is that as long as >>>>> you don't use `-zzstd` ++ `-E48bit`, it should be fine. >>>>> >>>>> If you need smaller images, I suggest: `-zlzma,9 -C65536 -Efragments` >>>>> Or like Android, they all use `-zlz4hc`, >>>>> Or zstd, but don't add `-E48bit`. >>>>> >>>>> As for "--max-extent-bytes 65536", it can be dropped >>>>> since if `-E48bit` is not used, it only has negative >>>>> impacts. >>>>> >>>>> In short, `-E48bit` + `-zzstd` + `--max-extent-bytes` >>>>> enables new unaligned compression for zstd, but it's >>>>> a relatively new feature, I still still some time to >>>>> stablize it but my own time is limited and all things >>>>> are always prioritized. >>>> >>>> Ok, thanks for this advice! >>> >>> FYI, I can reproduce this issue locally with `-E48bit` >>> on in 600s. >>> >>> I do think it's a `-E48bit` + zstd issue so >>> non-`-E48bit` won't be impacted and I will find time >>> to troubleshoot it this week. >> >> Yes, without '-E48bit' we also can't reproduce it for entire weekend on several boards. No such panics. > > Can you check if the following informal patch resolves > this issue?  I've checked it locally: > > diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c > index 8a0b15511931..824ffe4b871c 100644 > --- a/fs/erofs/zdata.c > +++ b/fs/erofs/zdata.c > @@ -1509,12 +1509,6 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec, >      DBG_BUGON(z_erofs_is_shortlived_page(bvec->bv_page)); > >      folio = page_folio(zbv.page); > -    /* For preallocated managed folios, add them to page cache here */ > -    if (folio->private == Z_EROFS_PREALLOCATED_FOLIO) { > -        tocache = true; > -        goto out_tocache; > -    } > - >      mapping = READ_ONCE(folio->mapping); >      /* >       * File-backed folios for inplace I/Os are all locked steady, > @@ -1527,6 +1521,12 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec, >          return; >      } > > +    if (cmpxchg(&folio->private, Z_EROFS_PREALLOCATED_FOLIO, NULL) == > +        Z_EROFS_PREALLOCATED_FOLIO) { > +        tocache = true; > +        goto out_tocache; > +    } > + >      folio_lock(folio); >      if (likely(folio->mapping == mc)) { >          /* > @@ -1546,14 +1546,8 @@ static void z_erofs_fill_bio_vec(struct bio_vec *bvec, >              } >              return; >          } > -        /* > -         * Already linked with another pcluster, which only appears in > -         * crafted images by fuzzers for now.  But handle this anyway. > -         */ > -        tocache = false;    /* use temporary short-lived pages */ >      } else { > -        DBG_BUGON(1); /* referenced managed folios can't be truncated */ > -        tocache = true; > +        DBG_BUGON(1);        /* referenced managed folios can't be truncated */ >      } >      folio_unlock(folio); >      folio_put(folio); > > > I will form a formal patch later with comments and commit > message later. Hi, thanks! I'll test it! > > Thanks, > Gao Xiang