Skip to contentSkip to conversation

erofs-utils: lib: error out if fragment_off is crafted

PATCH Superseded Gao Xiang 1 participant 1 message Mar 7, 2025 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: lib: error out if fragment_off is crafted

Found in some fuzzed images.

Fixes f511cfbbc0da ("erofs-utils: introduce fragment cache")
---
 lib/fragments.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/fragments.c +4 -0
index 2f5fbf9..a345acf 100644
@@ -524,6 +524,10 @@ int erofs_packedfile_read(struct erofs_sb_info *sbi,
 			erofs_blk_t bnr = erofs_blknr(sbi, pos);
 			bool uptodate;
 
+			if (__erofs_unlikely(bnr > epi->uptodate_size)) {
+				erofs_err("packed inode EOF exceeded @ %llu", pos);
+				return -EFSCORRUPTED;
+			}
 			map.m_la = round_down(pos, bsz);
 			len = min_t(erofs_off_t, bsz - (pos & (bsz - 1)),
 				    end - pos);
Signature · 1 line
2.43.5