All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <xiang@kernel.org>
To: Yifan Zhao <stopire@gmail.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH 8/8] erofs-utils: fix read error and short read handling
Date: Fri, 13 Nov 2026 00:41:31 +0100	[thread overview]
Message-ID: <avZOq-NOdK64QAYQ@MacBookPro.fritz.box> (raw)
In-Reply-To: <20261112124725.2774244-9-stopire@gmail.com>

On Thu, Nov 12, 2026 at 08:47:25PM +0800, Yifan Zhao wrote:
> Several erofs_io_read() and erofs_io_pread() callers mishandle negative
> errors or unexpected short reads, potentially reporting success or
> looping at EOF.
> 
> Propagate negative errors, reject unexpected short reads and premature
> EOF, and preserve the result reported by the ublk handler.
> 
> Also cap OCI blob copies at the requested length.
> 
> Assisted-by: Codex:gpt-6-astra
> Assisted-by: Claude Code:deepseek-v4.1-flash-1017
> Signed-off-by: Yifan Zhao <stopire@gmail.com>
> ---
>  lib/backends/fanotify.c |  3 ++-
>  lib/backends/nbd.c      |  2 ++
>  lib/backends/ublk.c     |  2 +-
>  lib/compress.c          |  2 +-
>  lib/fragments.c         |  2 +-
>  lib/inode.c             | 11 +++++------
>  lib/remotes/oci.c       |  1 +
>  lib/super.c             |  2 +-
>  mount/main.c            | 10 +++++-----
>  9 files changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/lib/backends/fanotify.c b/lib/backends/fanotify.c
> index cf8b616..898ea84 100644
> --- a/lib/backends/fanotify.c
> +++ b/lib/backends/fanotify.c
> @@ -169,7 +169,8 @@ static int erofs_fanotify_handle_range(struct erofs_fanotify_ctx *ctx,
>  		  (unsigned long long)(offset + length));
>  
>  	read_len = erofs_io_pread(&ctx->vd, ctx->fetch_buf, length, offset);
> -	if (read_len < 0) {
> +	if (read_len != length) {
> +		read_len = read_len < 0 ? read_len : -EIO;
>  		erofs_err("Failed to fetch range [%llu, %llu): %s",
>  			  (unsigned long long)offset,
>  			  (unsigned long long)(offset + length),
> diff --git a/lib/backends/nbd.c b/lib/backends/nbd.c
> index db0df44..81506b1 100644
> --- a/lib/backends/nbd.c
> +++ b/lib/backends/nbd.c
> @@ -600,6 +600,8 @@ int erofs_nbd_get_request(int skfd, struct erofs_nbd_request *rq)
>  	int err;
>  
>  	err = erofs_io_read(&vf, rq, sizeof(*rq));
> +	if (err < 0)
> +		return err;
>  	if (err < sizeof(*rq))
>  		return -EPIPE;
>  
> diff --git a/lib/backends/ublk.c b/lib/backends/ublk.c
> index d2c5e19..7fa88d9 100644
> --- a/lib/backends/ublk.c
> +++ b/lib/backends/ublk.c
> @@ -630,7 +630,7 @@ static int ublk_handle_io(struct erofs_ublk_queue *q, int tag)
>  		if (ret < 0)
>  			io->result = ret;
>  		else
> -			io->result = req.nr_sectors << 9;
> +			io->result = req.result;

I don't apply this one, because I think there are two many changes
related to different interfaces.

especially this one, I don't know what happens just according to
the code here.

Could you just split this into multiple patch, each patch address one
interface, like erofs_io_pread()... etc.

I applied the remaining ones, so next time just resend these two.

Thanks,
Gao Xiang


      reply	other threads:[~2026-11-12 23:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:47 [PATCH 0/8] erofs-utils: fix issues found by LLMs Yifan Zhao
2026-11-12 12:47 ` [PATCH 1/8] erofs-utils: lib: fix arithmetic overflow in large file handling Yifan Zhao
2026-11-12 12:47 ` [PATCH 2/8] erofs-utils: mkfs: fix incremental superblock stack overread Yifan Zhao
2026-11-12 12:47 ` [PATCH 3/8] erofs-utils: tar: fix out-of-bounds access when trimming PAX paths Yifan Zhao
2026-11-12 12:47 ` [PATCH 4/8] erofs-utils: lib: fix buffer leaks in error paths Yifan Zhao
2026-11-12 23:20   ` Gao Xiang
2026-11-12 12:47 ` [PATCH 5/8] erofs-utils: exclude: fix stack overflow when checking long paths Yifan Zhao
2026-11-12 12:47 ` [PATCH 6/8] erofs-utils: lib: fix gzran EOF handling and state leaks Yifan Zhao
2026-11-12 12:47 ` [PATCH 7/8] erofs-utils: lib: fix metabox inline data reads Yifan Zhao
2026-11-12 12:47 ` [PATCH 8/8] erofs-utils: fix read error and short read handling Yifan Zhao
2026-11-12 23:41   ` 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=avZOq-NOdK64QAYQ@MacBookPro.fritz.box \
    --to=xiang@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=stopire@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.