From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B7E263955DC; Tue, 12 May 2026 17:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778608206; cv=none; b=oBFmn1Jtv8PEqM0l+hFt41RLiSN/Gwi5EaTUkYkrEeg8pAagMcPm1o/dfUeGHAeVZw1RpBgt2cHNn1j+v7x4Feq2z9Y+4SJk9AbRNDZS/afqAJTkPhM2o+Dz3jM24N1+IdH27Qv5cHZXD/lqOCW7a+Psl5VofN4FuEzKCnHmi20= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778608206; c=relaxed/simple; bh=idLBVUBklCttT20jFIysP4AKCGmlIgsdhme2w32T0VM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aT/XwXBDY1feRnbIFfuEwrUiHVcvD196g7CO7/UyDOsnA4aJ2po3JU/rg70AmuJYV1+6A3jXh0DUf0CqCOFbERITVy+kotIq4Aimd4jKbdIAQniFBVuydW3RivkXf77QRtjOznQcAwXnH/qXe+GI3EbFZJwQCXADQbM+Q3QaLyg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MC/hdCwR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MC/hdCwR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 187A6C2BCB0; Tue, 12 May 2026 17:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778608206; bh=idLBVUBklCttT20jFIysP4AKCGmlIgsdhme2w32T0VM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MC/hdCwRZ0FtNP4bG8m4e2vFzAKzMTJEEcvYUkEw6UcbsVDwkY4MhYD6k/Ha0ga/g D1ZEIarGfrDmcw8s1jfsXcKOO+FAyB+6EcfTDvteswaeStmUzhLfO73EVI/fSOU6jL bJjEhOUZyEf+/4udaDM6uQ7BCw1Q/EK56G4fhAaI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Gao Xiang , Sasha Levin Subject: [PATCH 6.12 194/206] erofs: fix unsigned underflow in z_erofs_lz4_handle_overlap() Date: Tue, 12 May 2026 19:40:46 +0200 Message-ID: <20260512173936.979307148@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173932.810559588@linuxfoundation.org> References: <20260512173932.810559588@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo [ Upstream commit 21e161de2dc660b1bb70ef5b156ab8e6e1cca3ab ] Some crafted images can have illegal (!partial_decoding && m_llen < m_plen) extents, and the LZ4 inplace decompression path can be wrongly hit, but it cannot handle (outpages < inpages) properly: "outpages - inpages" wraps to a large value and the subsequent rq->out[] access reads past the decompressed_pages array. However, such crafted cases can correctly result in a corruption report in the normal LZ4 non-inplace path. Let's add an additional check to fix this for backporting. Reproducible image (base64-encoded gzipped blob): H4sIAJGR12kCA+3SPUoDQRgG4MkmkkZk8QRbRFIIi9hbpEjrHQI5ghfwCN5BLCzTGtLbBI+g dilSJo1CnIm7GEXFxhT6PDDwfrs73/ywIQD/1ePD4r7Ou6ETsrq4mu7XcWfj++Pb58nJU/9i PNtbjhan04/9GtX4qVYc814WDqt6FaX5s+ZwXXeq52lndT6IuVvlblytLMvh4Gzwaf90nsvz 2DF/21+20T/ldgp5s1jXRaN4t/8izsy/OUB6e/Qa79r+JwAAAAAAAL52vQVuGQAAAP6+my1w ywAAAAAAAADwu14ATsEYtgBQAAA= $ mount -t erofs -o cache_strategy=disabled foo.erofs /mnt $ dd if=/mnt/data of=/dev/null bs=4096 count=1 Fixes: 598162d05080 ("erofs: support decompress big pcluster for lz4 backend") Reported-by: Yuhao Jiang Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo Reviewed-by: Gao Xiang Signed-off-by: Gao Xiang Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/erofs/decompressor.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/erofs/decompressor.c +++ b/fs/erofs/decompressor.c @@ -149,6 +149,7 @@ static void *z_erofs_lz4_handle_overlap( oend = rq->pageofs_out + rq->outputsize; omargin = PAGE_ALIGN(oend) - oend; if (!rq->partial_decoding && may_inplace && + rq->outpages >= rq->inpages && omargin >= LZ4_DECOMPRESS_INPLACE_MARGIN(rq->inputsize)) { for (i = 0; i < rq->inpages; ++i) if (rq->out[rq->outpages - rq->inpages + i] !=