From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 427CA3A1E8A for ; Mon, 29 Dec 2025 09:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767000600; cv=none; b=uAmQQ15S6X8YFCK/aKgDUjecqjRj9+7wGSpjjRloDHfD3LIVm1yUlAgX7PA7cKAOTPSOjLbi+FScHaRViqzwMc6OoMuHTEJip0OnsrRGmalGKjFzUaAsl4JtejcB2bbHKBrNWqa/LkMQ4iqHOsAGUaM/mdeGmR3QxAhhxFmRolY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767000600; c=relaxed/simple; bh=USYSeCOyL8ltzzowAncQd2Hf3yNOdfq+1KgV3qhvoOI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AyN9oOmLVa2PG+FycDZ3wcjB69Z55kC4VdzPZBZOhOf8ZSrqCcqbDGTCMSbZPOaHRB9jX/k51gxz2ks2AuxXsC7VrV6wfJPc0DakT4lg9nCKDwr5Ee9jFGhMe2SR6XdlCKNE6qHBoNXKOHhMVI+JPxSTkXEJsiGzbTIDyuE/h80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=W6CFUyBQ; arc=none smtp.client-ip=115.124.30.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="W6CFUyBQ" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1767000594; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=DTcDrCKHuE1wXLhx8R4H8p8WcGuOFBc484to9LdCtVU=; b=W6CFUyBQb4lBISxrDCBhRpcYPq4ts+oVkvu1nm85+cU5naE8y0Q5Ds0z5OSmA8Tl9l2pVimf/0tBrA9RvyO362jLnTnZk8SIbgvlB66PRN565uJLx47+A78FQ2ihl1fDh97rHDdJU4is/4ZYybSsdPuVdurLizsVxstA7HGJQmw= Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Wvqzdqv_1767000589 cluster:ay36) by smtp.aliyun-inc.com; Mon, 29 Dec 2025 17:29:53 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , Gao Xiang Subject: [PATCH 1/4] erofs: fix incorrect early exits for invalid metabox-enabled images Date: Mon, 29 Dec 2025 17:29:46 +0800 Message-ID: <20251229092949.2316075-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 414091322c63 ("erofs: implement metadata compression") Signed-off-by: Gao Xiang --- fs/erofs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 937a215f626c..2e4d0ea2ffa1 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -330,12 +330,13 @@ static int erofs_read_superblock(struct super_block *sb) } sbi->packed_nid = le64_to_cpu(dsb->packed_nid); if (erofs_sb_has_metabox(sbi)) { + ret = -EFSCORRUPTED; if (sbi->sb_size <= offsetof(struct erofs_super_block, metabox_nid)) - return -EFSCORRUPTED; + goto out; 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 */ + goto out; /* self-loop detection */ } sbi->inos = le64_to_cpu(dsb->inos); -- 2.43.5