From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH 2/3] s390/crypto: Rework ctr_paes_do_crypt() to remove conditional locking
Date: Tue, 04 Aug 2026 11:47:00 +0000 [thread overview]
Message-ID: <20260804114701.54ADE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804113736.1423667-3-hca@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Silent data corruption when skcipher_walk_done() mapping errors are overwritten by paes_convert_key() false success.
--
--- Patch [2]: [PATCH 2/3] s390/crypto: Rework ctr_paes_do_crypt() to remove conditional locking ---
commit fd135aacfa5dd1086ab5711e4513f6e0edede1dc
Author: Heiko Carstens <hca@linux.ibm.com>
s390/crypto: Rework ctr_paes_do_crypt() to remove conditional locking
This commit extracts the core loop of ctr_paes_do_crypt() into a new
helper function, __ctr_paes_do_crypt(), to avoid conditionally taken locks
that trip up Clang's static analysis.
> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index 8cfe6166c193c..d4a9108d39f5f 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
[ ... ]
> @@ -981,34 +955,76 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
> k = cpacf_kmctr(ctx->fc, param, walk->dst.virt.addr,
> walk->src.virt.addr, n, ctrptr);
> if (k) {
> - if (ctrptr == ctrblk)
> + if (ctrptr == ctrblk) {
> memcpy(walk->iv, ctrptr + k - AES_BLOCK_SIZE,
> AES_BLOCK_SIZE);
> + }
> crypto_inc(walk->iv, AES_BLOCK_SIZE);
> rc = skcipher_walk_done(walk, nbytes - k);
> }
> if (k < n) {
> if (!maysleep) {
> - if (locked)
> - mutex_unlock(&ctrblk_lock);
> rc = -EKEYEXPIRED;
> goto out;
> }
> rc = paes_convert_key(ctx, tested);
[Severity: High]
This is a pre-existing issue, but does this sequence overwrite an error
from skcipher_walk_done()?
If the hardware stops processing early (k < n) and skcipher_walk_done() fails
to map the next scatterlist chunk, it can return a negative error code
like -ENOMEM into rc.
However, execution then immediately enters the if (k < n) block where rc is
unconditionally overwritten. If !maysleep, rc becomes -EKEYEXPIRED. If
paes_convert_key() is called and succeeds, rc becomes 0.
Could this result in silent data corruption where an incomplete encryption is
treated as a success (rc = 0) by the caller?
> - if (rc) {
> - if (locked)
> - mutex_unlock(&ctrblk_lock);
> + if (rc)
> goto out;
> - }
> spin_lock_bh(&ctx->pk_lock);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260804113736.1423667-1-hca@linux.ibm.com?part=2
next prev parent reply other threads:[~2026-08-04 11:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 11:37 [PATCH 0/3] s390/crypto: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-04 11:37 ` [PATCH 1/3] s390/crypto: Rework ctr_aes_crypt() to remove conditional locking Heiko Carstens
2026-08-04 11:44 ` sashiko-bot
2026-08-04 11:37 ` [PATCH 2/3] s390/crypto: Rework ctr_paes_do_crypt() " Heiko Carstens
2026-08-04 11:47 ` sashiko-bot [this message]
2026-08-04 12:47 ` Heiko Carstens
2026-08-05 8:47 ` Harald Freudenberger
2026-08-04 11:37 ` [PATCH 3/3] s390/crypto: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-04 11:45 ` 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=20260804114701.54ADE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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.