From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Haren Myneni <haren@us.ibm.com>,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org>,
"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Thorsten Blum <blum@kernel.org>, Bulent Abali <abali@us.ibm.com>,
Robert Jennings <rcj@linux.vnet.ibm.com>,
Seth Jennings <sjenning@linux.vnet.ibm.com>,
Dan Streetman <ddstreet@ieee.org>,
linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 03/10] crypto: nx - Fix bounce buffer copy overflow in decompress()
Date: Mon, 23 Nov 2026 15:09:54 +0000 [thread overview]
Message-ID: <20261123151055.2533735-4-lee@kernel.org> (raw)
In-Reply-To: <20261123151055.2533735-1-lee@kernel.org>
When decompress() falls back to software 842 decompression and the
remaining destination capacity p->oremain is smaller than required_len,
it redirects decompression into the bounce buffer ctx->dbounce with
dlen set to BOUNCE_BUFFER_SIZE.
After sw842_decompress() completes and ignore bytes are subtracted,
decompress() copies dlen bytes from ctx->dbounce into p->out via
memcpy() before update_param() validates that dlen does not exceed
p->oremain. A crafted compressed stream whose decompressed output
exceeds p->oremain therefore overflows the caller's destination buffer
by up to BOUNCE_BUFFER_SIZE bytes.
Validate that dlen does not exceed p->oremain and return -ENOSPC before
copying out of ctx->dbounce.
Fixes: ed70b479c2c0 ("crypto: nx - add hardware 842 crypto comp alg")
Closes: https://sashiko.dev/#/bug/linux-7309787b-8efe-4919-bb31-c4d9eceb9c0f
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/crypto/nx/nx-842.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c
index b4404a138962..4f96c2b2397b 100644
--- a/drivers/crypto/nx/nx-842.c
+++ b/drivers/crypto/nx/nx-842.c
@@ -427,8 +427,11 @@ static int decompress(struct nx842_crypto_ctx *ctx,
if (ignore)
pr_debug("ignoring last %x bytes\n", ignore);
- if (dst == ctx->dbounce)
+ if (dst == ctx->dbounce) {
+ if (dlen > p->oremain)
+ return -ENOSPC;
memcpy(p->out, dst, dlen);
+ }
pr_debug("decompress slen %x padding %x dlen %x ignore %x\n",
slen, padding, dlen, ignore);
--
2.56.1.750.gf70dc682cf-goog
next prev parent reply other threads:[~2026-11-23 15:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:09 [PATCH 00/10] crypto: Assorted bug fixes across crypto drivers Lee Jones
2026-11-23 15:09 ` [PATCH 01/10] crypto: caam - Fix descriptor buffer overflow in caam_process_blob() Lee Jones
2026-11-23 15:09 ` [PATCH 02/10] crypto: marvell - Fix AEAD key buffer overflow for SHA-384/512 HMAC Lee Jones
2026-11-23 15:09 ` Lee Jones [this message]
2026-11-23 15:09 ` [PATCH 04/10] crypto: sun8i-ss - Fix scatterlist array overflow for HMAC requests Lee Jones
2026-11-23 15:09 ` [PATCH 05/10] crypto: hisilicon/hpre - Fix buffer overflow on odd ECDH input size Lee Jones
2026-11-23 15:09 ` [PATCH 06/10] crypto: talitos - Remove duplicate IV unmap in AEAD encrypt path Lee Jones
2026-11-23 15:09 ` [PATCH 07/10] crypto: safexcel - Check scatterlist errors before max() for in-place Lee Jones
2026-11-23 15:09 ` [PATCH 08/10] crypto: qce - Pass mapped scatterlist count to qce_dma_prep_sgs() Lee Jones
2026-11-23 15:10 ` [PATCH 09/10] crypto: qce - Terminate RX DMA channel if TX preparation fails Lee Jones
2026-11-23 15:10 ` [PATCH 10/10] crypto: atmel-tdes - Update output IV before clearing busy flag Lee Jones
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=20261123151055.2533735-4-lee@kernel.org \
--to=lee@kernel.org \
--cc=abali@us.ibm.com \
--cc=blum@kernel.org \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=ddstreet@ieee.org \
--cc=haren@us.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
--cc=rcj@linux.vnet.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sjenning@linux.vnet.ibm.com \
--cc=sshegde@linux.ibm.com \
--cc=stable@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®