From: Sean Snider <ssnider5@outlook.com>
To: "herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] lib/lzo: check output space before writing the RLE header
Date: Fri, 16 Oct 2026 17:09:03 +0000 [thread overview]
Message-ID: <20261016170857.44908-1-ssnider5@outlook.com> (raw)
The safe LZO-RLE compressor writes its two-byte version header before
checking the available output space. With an output capacity of zero or
one, these stores exceed the supplied limit. Advancing op past op_end
also makes the unsigned HAVE_OP() comparison accept later writes.
Check for the two header bytes before emitting them. Use the existing
output_overrun path, leaving the output length unchanged on this error.
Ordinary LZO does not emit this header. Valid output is unchanged.
Bounded userspace tests of the kernel codec under ASan/UBSan reproduced
the boundary violation and passed after the correction. Successful
full-capacity streams remained byte-identical, and the existing Crypto
LZO and LZO-RLE compression vectors passed.
Fixes: cc47f07234f7 ("crypto: lzo - Fix compression buffer overrun")
Assisted-by: LLM
Signed-off-by: Sean Snider <ssnider5@outlook.com>
---
lib/lzo/lzo1x_compress.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c
index 01586af23..621bbb969 100644
--- a/lib/lzo/lzo1x_compress.c
+++ b/lib/lzo/lzo1x_compress.c
@@ -349,6 +349,7 @@ static int LZO_SAFE(lzogeneric1x_1_compress)(
// LZO v0 will never write 17 as first byte (except for zero-length
// input), so this is used to version the bitstream
if (bitstream_version > 0) {
+ NEED_OP(2);
*op++ = 17;
*op++ = bitstream_version;
m4_max_offset = M4_MAX_OFFSET_V1;
--
2.43.0
next reply other threads:[~2026-10-16 17:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 17:09 Sean Snider [this message]
2026-11-06 11:28 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261016170857.44908-1-ssnider5@outlook.com \
--to=ssnider5@outlook.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®