[PATCH] erofs-utils: handle crafted fragments in the packed inode
Gao Xiang
hsiangkao at linux.alibaba.com
Sun Apr 27 18:30:13 AEST 2025
Should error out this invalid case immediately.
Fixes: 654a9be311a1 ("erofs-utils: lib: support fragments")
Closes: https://github.com/erofs/erofs-utils/issues/18
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/data.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/data.c b/lib/data.c
index 28460ef..0f79f78 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -249,6 +249,11 @@ int z_erofs_read_one_data(struct erofs_inode *inode,
int ret = 0;
if (map->m_flags & EROFS_MAP_FRAGMENT) {
+ if (__erofs_unlikely(inode->nid == sbi->packed_nid)) {
+ erofs_err("fragment should not exist in the packed inode %llu",
+ sbi->packed_nid | 0ULL);
+ return -EFSCORRUPTED;
+ }
return erofs_packedfile_read(sbi, buffer, length - skip,
inode->fragmentoff + skip);
}
--
2.43.5
More information about the Linux-erofs
mailing list