From: sashiko-bot@kernel.org
To: "Haoxiang Li" <haoxiang_li2024@163.com>,
herbert@gondor.apana.org.au, davem@davemloft.net,
johnpol@2ka.mipt.ru, linux-crypto@vger.kernel.org
Subject: Re: [PATCH] crypto: hifn_795x - Free walk pages on session setup failure
Date: Wed, 18 Nov 2026 06:38:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-220265@kernel.org> (raw)
In-Reply-To: <20261118061917.2093148-1-haoxiang_li2024@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] crypto: hifn_795x: out-of-bounds access in
hifn_process_ready() after -EAGAIN
--
commit 36e24dad40a71397ed983775cdb1b3eac820b6a2
Author: Haoxiang Li <haoxiang_li2024@163.com>
crypto: hifn_795x - Free walk pages on session setup failure
This commit calls hifn_cipher_walk_exit() in the hifn_setup_session()
error paths to free temporary walk pages allocated for misaligned
destination scatterlists.
> diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
> index 46bcef0446067..73a661085d974 100644
> --- a/drivers/crypto/hifn_795x.c
> +++ b/drivers/crypto/hifn_795x.c
> @@ -1539,7 +1539,7 @@ static int hifn_setup_session(struct skcipher_request *req)
> sg_num = hifn_cipher_walk(req, &rctx->walk);
> if (sg_num < 0) {
> err = sg_num;
> - goto err_out_exit;
> + goto err_out_free;
> }
>
> spin_lock_irqsave(&dev->lock, flags);
> @@ -1561,6 +1561,9 @@ static int hifn_setup_session(struct skcipher_request *req)
>
> err_out:
> spin_unlock_irqrestore(&dev->lock, flags);
> +err_out_free:
> + if (rctx->walk.flags & ASYNC_FLAGS_MISALIGNED)
> + hifn_cipher_walk_exit(&rctx->walk);
> err_out_exit:
> if (err) {
> dev_info(&dev->pdev->dev, "iv: %p [%d], key: %p [%d], mode: %u, op: %u, "
[Severity: Medium]
Can this cause an out-of-bounds access on rctx->walk.cache[] in
hifn_process_ready() when hifn_setup_session() fails with -EAGAIN?
When a misaligned request has more than ASYNC_SCATTERLIST_CACHE (16)
destination segments that coalesce into fewer cache pages during
hifn_cipher_walk(), hitting the -EAGAIN path calls
hifn_cipher_walk_exit(), which zeroes w->cache[i].length and w->num while
leaving ASYNC_FLAGS_MISALIGNED set in rctx->walk.flags. hifn_handle_req()
then enqueues the request into dev->queue. If hifn_remove() ->
hifn_flush() later drains dev->queue via hifn_process_ready(), it sees
ASYNC_FLAGS_MISALIGNED still set and enters the walk loop:
drivers/crypto/hifn_795x.c:hifn_process_ready() {
if (rctx->walk.flags & ASYNC_FLAGS_MISALIGNED) {
...
while (nbytes) {
t = &rctx->walk.cache[idx];
dst = &req->dst[idx];
...
if (!t->length) {
nbytes -= min(dst->length, nbytes);
idx++;
continue;
}
Because every cache entry now has t->length == 0 instead of advancing
across coalesced segments via skcipher_get(), idx increments once per
req->dst segment and indexes past rctx->walk.cache[16] and the end of
struct hifn_request_context. Clearing ASYNC_FLAGS_MISALIGNED in
hifn_cipher_walk_exit() (or under err_out_free) would avoid walking an
already-freed cipher walk.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118061917.2093148-1-haoxiang_li2024@163.com?part=1
next prev parent reply other threads:[~2026-11-18 6:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 6:19 [PATCH] crypto: hifn_795x - Free walk pages on session setup failure Haoxiang Li
2026-11-18 6:38 ` sashiko-bot [this message]
2026-11-18 6:55 ` Eric Biggers
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-220265@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=davem@davemloft.net \
--cc=haoxiang_li2024@163.com \
--cc=herbert@gondor.apana.org.au \
--cc=johnpol@2ka.mipt.ru \
--cc=linux-crypto@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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