All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH v1 1/3] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms
Date: Fri, 14 Aug 2026 14:48:15 +0000	[thread overview]
Message-ID: <20260814144815.B5C4C1F00ADB@smtp.kernel.org> (raw)
In-Reply-To: <20260814142200.65821-2-freude@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The crypto engine async callback functions (e.g., ecb_paes_do_one_request, cbc_paes_do_one_request) double-complete requests upon failure.
--

--- Patch [1]: [PATCH v1 1/3] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms ---
commit 9fb1966e4b16413a77ebe1ccd447f231c3b30ec4
Author: Harald Freudenberger <freude@linux.ibm.com>
Subject: s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms

This commit adds immediate error checks after skcipher_walk_done in the
main processing loops for PAES algorithms. It ensures walk errors are
propagated properly instead of being masked, and checks walk->nbytes to
avoid double de-allocation.

> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
[ ... ]
> @@ -558,7 +561,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq)
>  		cond_resched();
>  		pr_debug("rescheduling request\n");
>  		return -ENOSPC;
> -	} else if (rc) {
> +	} else if (rc && walk->nbytes) {
>  		skcipher_walk_done(walk, rc);
>  	}
>  
>  	memzero_explicit(&req_ctx->param, sizeof(req_ctx->param));
>  	pr_debug("request complete with rc=%d\n", rc);
>  	local_bh_disable();
>  	atomic_dec(&ctx->via_engine_ctr);
>  	crypto_finalize_skcipher_request(engine, req, rc);
>  	local_bh_enable();
>  	return rc;

[Severity: High]
This is a pre-existing issue, but can returning a negative rc here cause a
double-completion of the request?

If an error occurs during cryptographic processing (for example, if
paes_convert_key() fails and returns a negative rc), the code calls
crypto_finalize_skcipher_request() which completes the request once.

It then returns that same negative rc to the caller. Does the crypto engine
core (in crypto_pump_requests) see this negative return value and execute its
own error path, completing the exact same request a second time?

Could this result in a use-after-free or double-free, since callers might
drop references multiple times when a request is completed twice? This
identical pattern appears to exist across all the PAES cipher modes
(ecb_paes_do_one_request, cbc_paes_do_one_request, ctr_paes_do_one_request,
and xts_paes_do_one_request).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260814142200.65821-1-freude@linux.ibm.com?part=1

  reply	other threads:[~2026-08-14 14:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 14:21 [PATCH v1 0/3] Fixes and rework for paes_s390 Harald Freudenberger
2026-08-14 14:21 ` [PATCH v1 1/3] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-14 14:48   ` sashiko-bot [this message]
2026-08-14 14:21 ` [PATCH v1 2/3] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-14 14:31   ` sashiko-bot
2026-08-14 14:22 ` [PATCH v1 3/3] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-14 14:44   ` sashiko-bot

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=20260814144815.B5C4C1F00ADB@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.