public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: lib: handle short reads in inode fingerprint
@ 2026-04-20 18:23 Vansh Choudhary
  0 siblings, 0 replies; only message in thread
From: Vansh Choudhary @ 2026-04-20 18:23 UTC (permalink / raw)
  To: linux-erofs; +Cc: Vansh Choudhary

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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-20 18:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 18:23 [PATCH] erofs-utils: lib: handle short reads in inode fingerprint Vansh Choudhary

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox