From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH v4 5/7] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine
Date: Wed, 19 Aug 2026 09:30:00 +0000 [thread overview]
Message-ID: <20260819093000.BA3601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260819091734.7331-6-freude@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch corrects the handling of the `-EBUSY` return code for the crypto engine in `paes_s390.c` but fails to apply the identical fix to `phmac_s390.c`, leading to state corruption and Use-After-Free.
- [High] The `do_one_request` engine callbacks complete the crypto request twice if a synchronous error occurs during processing, leading to a double completion and Use-After-Free.
--
--- Patch [5]: [PATCH v4 5/7] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine ---
commit 3e0f47412e8d6356e198b6481361a3ba704da13f
Author: Harald Freudenberger <freude@linux.ibm.com>
s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine
This commit adds -EBUSY as a successful return code when transferring
skcipher requests to the crypto engine in paes_s390.c. This prevents
state cleanup on requests that are successfully queued on the backlog.
> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index 03446bfac37f2..2048327c1ffe4 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
> @@ -494,15 +495,17 @@ static int ecb_paes_crypt(struct skcipher_request *req, unsigned long modifier)
> if (rc == 0 || rc == -EKEYEXPIRED) {
> atomic_inc(&ctx->via_engine_ctr);
> rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req);
> - if (rc != -EINPROGRESS)
> + if (rc == -EINPROGRESS || rc == -EBUSY)
> + cleanup = false;
> + else
> atomic_dec(&ctx->via_engine_ctr);
> }
[Severity: High]
This isn't a bug introduced by this patch, but should the same fix be applied
to the hash requests in phmac_s390.c?
For example, in phmac_update():
arch/s390/crypto/phmac_s390.c:phmac_update() {
...
if (rc == 0 || rc == -EKEYEXPIRED) {
req_ctx->async_op = OP_UPDATE;
atomic_inc(&tfm_ctx->via_engine_ctr);
rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req);
if (rc != -EINPROGRESS)
atomic_dec(&tfm_ctx->via_engine_ctr);
}
if (rc != -EINPROGRESS) {
hwh_advance(hwh, rc);
memzero_explicit(kmac_ctx, sizeof(*kmac_ctx));
}
...
}
It looks like phmac_update, phmac_final, and phmac_finup also incorrectly
treat -EBUSY as a failure, which could dismantle the state needed by the
engine thread.
[ ... ]
[Severity: High]
This is a pre-existing issue, but could the do_one_request callbacks lead to
a double completion if a synchronous error occurs?
In ecb_paes_do_one_request():
arch/s390/crypto/paes_s390.c:ecb_paes_do_one_request() {
...
crypto_finalize_skcipher_request(engine, req, rc);
local_bh_enable();
return rc;
}
If rc is negative, does returning it here after calling
crypto_finalize_skcipher_request() force the engine thread to incorrectly
complete the request a second time?
Could this also affect cbc_paes_do_one_request(), ctr_paes_do_one_request(),
xts_paes_do_one_request(), and phmac_do_one_request()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260819091734.7331-1-freude@linux.ibm.com?part=5
next prev parent reply other threads:[~2026-08-19 9:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 9:17 [PATCH v4 0/7] Fixes and rework for paes_s390 and phmac_s390 Harald Freudenberger
2026-08-19 9:17 ` [PATCH v4 1/7] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-19 9:31 ` sashiko-bot
2026-08-19 9:17 ` [PATCH v4 2/7] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-19 9:30 ` sashiko-bot
2026-08-19 9:17 ` [PATCH v4 3/7] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-19 9:27 ` sashiko-bot
2026-08-19 9:17 ` [PATCH v4 4/7] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-19 9:22 ` sashiko-bot
2026-08-19 9:17 ` [PATCH v4 5/7] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-19 9:30 ` sashiko-bot [this message]
2026-08-19 9:47 ` Holger Dengler
2026-08-19 9:17 ` [PATCH v4 6/7] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-19 9:37 ` sashiko-bot
2026-08-19 13:23 ` Harald Freudenberger
2026-08-19 14:03 ` Harald Freudenberger
2026-08-19 9:17 ` [PATCH v4 7/7] s390/crypto: Fix wrong return code to engine in asynch callbacks Harald Freudenberger
2026-08-19 9:28 ` sashiko-bot
2026-08-19 10:00 ` Holger Dengler
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=20260819093000.BA3601F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox