Skip to content
/ linux Public

Commit 041b516

Browse files
hsiangkaoSasha Levin
authored andcommitted
erofs: fix incorrect early exits for invalid metabox-enabled images
[ Upstream commit 643575d ] Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks. However, this does not cause system crashes or other severe issues. Fixes: 4140913 ("erofs: implement metadata compression") Cc: stable@kernel.org Reviewed-by: Hongbo Li <lihongbo22@huawei.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7074633 commit 041b516

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/erofs/super.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,13 @@ static int erofs_read_superblock(struct super_block *sb)
330330
}
331331
sbi->packed_nid = le64_to_cpu(dsb->packed_nid);
332332
if (erofs_sb_has_metabox(sbi)) {
333+
ret = -EFSCORRUPTED;
333334
if (sbi->sb_size <= offsetof(struct erofs_super_block,
334335
metabox_nid))
335-
return -EFSCORRUPTED;
336+
goto out;
336337
sbi->metabox_nid = le64_to_cpu(dsb->metabox_nid);
337338
if (sbi->metabox_nid & BIT_ULL(EROFS_DIRENT_NID_METABOX_BIT))
338-
return -EFSCORRUPTED; /* self-loop detection */
339+
goto out; /* self-loop detection */
339340
}
340341
sbi->inos = le64_to_cpu(dsb->inos);
341342

0 commit comments

Comments
 (0)