public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: linux-erofs@lists.ozlabs.org, Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH 1/2] erofs-utils: tar: fix out-of-bounds access when trimming pax path
Date: Tue, 14 Apr 2026 22:19:26 +0800	[thread overview]
Message-ID: <fb13fd1a-e929-4c7b-a8cd-ca0cc80d0ab0@linux.alibaba.com> (raw)
In-Reply-To: <20260414141313.46575-2-zhanxusheng@xiaomi.com>

Hi,

On 2026/4/14 22:13, Zhan Xusheng wrote:
> When a PAX extended header contains a path consisting entirely of '/'
> characters (e.g., "path=/"), the trailing-slash trimming loop in
> tarerofs_parse_pax_header() decrements j to 0, then accesses
> eh->path[-1] which is an out-of-bounds heap read.
> 
> The tar header path trimming had a similar issue fixed by commit
> dcd06f421003 ("erofs-utils: mkfs: tar: fix SIGSEGV on `/` entry"),
> but the PAX header path trimming was not addressed.
> 
> Add a j > 0 guard to the while condition.
> 
> Fixes: 95d315fd7958 ("erofs-utils: introduce tarerofs")
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>

That was addressed by others before: I think I will add
your `Signed-off-by:` into the original patch.

BTW, are you using LLM to discover bugs too?

Thanks,
Gao Xiang

> ---
>   lib/tar.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/tar.c b/lib/tar.c
> index eca29f5..3d92f48 100644
> --- a/lib/tar.c
> +++ b/lib/tar.c
> @@ -509,7 +509,7 @@ int tarerofs_parse_pax_header(struct erofs_iostream *ios,
>   				int j = p - 1 - value;
>   				free(eh->path);
>   				eh->path = strdup(value);
> -				while (eh->path[j - 1] == '/')
> +				while (j > 0 && eh->path[j - 1] == '/')
>   					eh->path[--j] = '\0';
>   			} else if (!strncmp(kv, "linkpath=",
>   					sizeof("linkpath=") - 1)) {



  reply	other threads:[~2026-04-14 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 14:13 [PATCH erofs-utils 0/2] tar: fix parsing issues for pax and GNU extensions Zhan Xusheng
2026-04-14 14:13 ` [PATCH 1/2] erofs-utils: tar: fix out-of-bounds access when trimming pax path Zhan Xusheng
2026-04-14 14:19   ` Gao Xiang [this message]
2026-04-14 14:46     ` [PATCH erofs-utils 0/2] tar: fix parsing issues for pax and GNU extensions Zhan Xusheng
2026-04-14 14:49       ` Gao Xiang
2026-04-14 14:55         ` Zhan Xusheng
2026-04-14 14:13 ` [PATCH 2/2] erofs-utils: tar: add missing NULL checks for GNU long name/link Zhan Xusheng

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=fb13fd1a-e929-4c7b-a8cd-ca0cc80d0ab0@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.com \
    /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