Skip to contentSkip to conversation

erofs-utils: handle crafted fragments in the packed inode

PATCH New Gao Xiang 1 participant 1 message Apr 27, 2025 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: handle crafted fragments in the packed inode

Should error out this invalid case immediately.

Fixes 654a9be311a1 ("erofs-utils: lib: support fragments")
---
 lib/data.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/data.c +5 -0
index 28460ef..0f79f78 100644
@@ -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);
 	}
Signature · 1 line
2.43.5