From: sashiko-bot@kernel.org
To: "Ryan Prinz" <rc4d5a@protonmail.com>,
"Zhiqi Song" <songzhiqi1@huawei.com>,
"Longfang Liu" <liulongfang@huawei.com>
Cc: "Herbert Xu" <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH 2/2] crypto: hisilicon/hpre - fix heap overflow on oversized ECDH public key
Date: Tue, 24 Nov 2026 09:34:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-230844@kernel.org> (raw)
In-Reply-To: <20261124092546.1712228-2-rc4d5a@protonmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] crypto: hisilicon/hpre: KPP API violation in
hpre_ecdh_msg_request_set() [1]
--
commit 5f542f1173f567ac087c4ed6d0f299ee8ae8b2d3
Author: Ryan Prinz <rc4d5a@protonmail.com>
crypto: hisilicon/hpre - fix heap overflow on oversized ECDH public key
This commit adds an explicit upper-bound check on len against
ctx->key_sz << 1 in hpre_ecdh_src_data_init() to prevent an odd length of
2 * ctx->key_sz + 1 from bypassing the len >> 1 check and overflowing the
DMA-coherent buffer.
> diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> index 80666bb71508e..0759465dd87ff 100644
> --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> @@ -1557,6 +1557,9 @@ static int hpre_ecdh_src_data_init(struct hpre_asym_request *hpre_req,
> int shift;
>
> /* Src_data include gx and gy. */
> + if (unlikely(len > ctx->key_sz << 1))
> + return -EINVAL;
> +
> shift = ctx->key_sz - (len >> 1);
> if (unlikely(shift < 0))
> return -EINVAL;
[Severity: High]
This problem wasn't introduced by this patch, but in the adjacent
hpre_ecdh_msg_request_set(), does checking req->dst_len < ctx->key_sz << 1
reject valid KPP shared-secret requests [1]?
drivers/crypto/hisilicon/hpre/hpre_crypto.c:hpre_ecdh_msg_request_set() {
...
if (req->dst_len < ctx->key_sz << 1) {
req->dst_len = ctx->key_sz << 1;
return -EOVERFLOW;
}
...
}
Standard KPP ECDH callers such as the Bluetooth subsystem expect only the
X coordinate of the shared secret and allocate a destination buffer of
ctx->key_sz bytes (e.g. 32 bytes for NIST P-256). Because the HPRE
hardware outputs both the X and Y coordinates and the driver writes
directly to req->dst instead of using a bounce buffer to copy out only the
X coordinate, those requests fail in hpre_ecdh_msg_request_set().
[1] https://sashiko.dev/#/bug/linux-8b3c97e2-4579-4201-94f1-2d9889a040fa
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124092546.1712228-1-rc4d5a@protonmail.com?part=2
prev parent reply other threads:[~2026-11-24 9:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 9:26 [PATCH 1/2] crypto: hisilicon/hpre - fix missing DH/ECDH public key validation Ryan Prinz
2026-11-24 9:26 ` [PATCH 2/2] crypto: hisilicon/hpre - fix heap overflow on oversized ECDH public key Ryan Prinz
2026-11-24 9:34 ` sashiko-bot [this message]
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=sashiko-outbox-230844@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=rc4d5a@protonmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=songzhiqi1@huawei.com \
/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