public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Vansh Choudhary <ch@vnsh.in>
To: linux-erofs@lists.ozlabs.org
Cc: Vansh Choudhary <ch@vnsh.in>
Subject: [PATCH] erofs-utils: lib: handle short reads in inode fingerprint
Date: Mon, 20 Apr 2026 23:53:18 +0530	[thread overview]
Message-ID: <20260420182318.61440-1-ch@vnsh.in> (raw)

Treat a zero-byte erofs_io_pread() return as I/O failure when
hashing inode->i_size bytes for the inode fingerprint.

Without that, pread() returning 0 on EOF (source shorter than
i_size, e.g. truncated between stat() and fingerprinting) leaves
"remaining" unchanged and mkfs.erofs spins forever.

Fixes: 5e7cdf7593ae ("erofs-utils: mkfs: add `--xattr-inode-digest` option")
Signed-off-by: Vansh Choudhary <ch@vnsh.in>
---
 lib/inode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/inode.c b/lib/inode.c
index b3e5f62..bac21dc 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -2005,6 +2005,8 @@ static int erofs_set_inode_fingerprint(struct erofs_inode *inode, int fd,
 				     min_t(u64, remaining, sizeof(buf)), pos);
 		if (ret < 0)
 			return ret;
+		if (!ret)
+			return -EIO;
 		if (ret > 0)
 			erofs_sha256_process(&md, buf, ret);
 		remaining -= ret;
-- 
2.43.0



                 reply	other threads:[~2026-04-20 18:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260420182318.61440-1-ch@vnsh.in \
    --to=ch@vnsh.in \
    --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