* Re: [PATCH] crypto: hifn_795x - Free walk pages on session setup failure
[not found] <20261118061917.2093148-1-haoxiang_li2024@163.com>
@ 2026-11-18 6:38 ` sashiko-bot
2026-11-18 6:55 ` Eric Biggers
1 sibling, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-18 6:38 UTC (permalink / raw)
To: Haoxiang Li, herbert, davem, johnpol, linux-crypto
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: hifn_795x - Free walk pages on session setup failure
[not found] <20261118061917.2093148-1-haoxiang_li2024@163.com>
2026-11-18 6:38 ` [PATCH] crypto: hifn_795x - Free walk pages on session setup failure sashiko-bot
@ 2026-11-18 6:55 ` Eric Biggers
1 sibling, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2026-11-18 6:55 UTC (permalink / raw)
To: Haoxiang Li; +Cc: herbert, davem, johnpol, linux-crypto, linux-kernel
On Wed, Nov 18, 2026 at 02:19:17PM +0800, Haoxiang Li wrote:
> hifn_setup_session() allocates temporary pages for misaligned destination
> buffers. If the scatterlist walk fails or the hardware queue has
> insufficient capacity, these pages are not released. Retrying a queued
> request reinitializes the walk cache, losing the previous page pointers.
> Add a separate cleanup path to release the pages for misaligned requests.
>
> Fixes: f7d0561ea1da ("[CRYPTO] hifn_795x: HIFN 795x driver")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
> drivers/crypto/hifn_795x.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
We should just delete this driver. It is heavily broken, 32-bit only,
and no one seems to have used it since 2008.
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 6:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261118061917.2093148-1-haoxiang_li2024@163.com>
2026-11-18 6:38 ` [PATCH] crypto: hifn_795x - Free walk pages on session setup failure sashiko-bot
2026-11-18 6:55 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox