erofs-utils: lib: avoid malformed metabox metadata
PATCH 1/1 erofs-utils: lib: avoid malformed metabox metadata
- If metadata compression is off, images shouldn't have METABOX-marked NIDs;
- metabox_nid itself shouldn't be METABOX-marked.
Fixes 7928074b7643 ("erofs-utils: introduce metadata compression [metabox]")
Signed-off-by Gao Xiang <[email protected]>
--- lib/data.c | 3 +++ lib/super.c | 2 ++ 2 files changed, 5 insertions(+)
lib/data.c +3 -0
@@ -30,6 +30,9 @@ void *erofs_bread(struct erofs_buf *buf, erofs_off_t offset, bool need_kmap)* cache to improve userspace metadata performance. */ if (!vf) { +if (!erofs_sb_has_metabox (sbi)) +return ERR_PTR (-EFSCORRUPTED ); + vi = (struct erofs_inode ) { .sbi = sbi, .nid = sbi->metabox_nid }; err =erofs_read_inode_from_disk (&vi);
lib/super.c +2 -0
@@ -133,6 +133,8 @@ int erofs_read_superblock(struct erofs_sb_info *sbi) metabox_nid))return -EFSCORRUPTED ; sbi->metabox_nid =le64_to_cpu (dsb->metabox_nid); +if (sbi->metabox_nid &BIT_ULL (EROFS_DIRENT_NID_METABOX_BIT )) +return -EFSCORRUPTED ;/* self-loop detection */ } sbi->inos =le64_to_cpu (dsb->inos); sbi->checksum =le32_to_cpu (dsb->checksum);
Signature · 1 line
2.43.5