Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <xiang@kernel.org>
To: bingying lan <lanbingying.lby@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org
Subject: Re: [PATCH] erofs-utils: lib: fix xattr prefix offset truncation
Date: Tue, 20 Oct 2026 15:45:19 +0200	[thread overview]
Message-ID: <atdwbyRJoiDjfFN5@MacBookPro> (raw)
In-Reply-To: <20261020055218.2953541-1-lanbingying.lby@linux.alibaba.com>

On Tue, Oct 20, 2026 at 01:52:18PM +0800, bingying lan wrote:
> xattr_prefix_start stores the long xattr prefix table offset in 4-byte
> units.  Casting the byte offset to u32 before shifting discards its
> upper bits, even though the overflow check accepts offsets whose
> shifted value fits in u32.  The table is written at the full offset,
> but the superblock points to the truncated location.
> 
> Shift the offset before narrowing it to u32.  This prevents corrupted
> images when incremental builds place the prefix table at or beyond
> 4 GiB.
> 
> Fixes: b6b741d8daaf ("erofs-utils: lib: get rid of tmpfile()")
> Signed-off-by: bingying lan <lanbingying.lby@linux.alibaba.com>
> ---
>  lib/xattr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/xattr.c b/lib/xattr.c
> index d86d94a..e742bfc 100644
> --- a/lib/xattr.c
> +++ b/lib/xattr.c
> @@ -921,7 +921,7 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)
>  		return -EOVERFLOW;
>  	start = offset;
>  
> -	sbi->xattr_prefix_start = (u32)offset >> 2;
> +	sbi->xattr_prefix_start = (u32)(offset >> 2);

oh, it seems an erofs-utils one, merging now.

Thanks,
Gao Xiang


      parent reply	other threads:[~2026-10-20 13:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  5:52 [PATCH] erofs-utils: lib: fix xattr prefix offset truncation bingying lan
2026-10-20 13:44 ` Gao Xiang
2026-10-20 13:45 ` Gao Xiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atdwbyRJoiDjfFN5@MacBookPro \
    --to=xiang@kernel.org \
    --cc=chao@kernel.org \
    --cc=lanbingying.lby@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox