From: Heiko Carstens <hca@linux.ibm.com>
To: Harald Freudenberger <freude@linux.ibm.com>,
Holger Dengler <dengler@linux.ibm.com>
Cc: 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, 4 Aug 2026 14:47:05 +0200 [thread overview]
Message-ID: <20260804124705.12261Cbe-hca@linux.ibm.com> (raw)
In-Reply-To: <20260804114701.54ADE1F000E9@smtp.kernel.org>
Harald, Holger,
> 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()?
What should happen with this? Can this be ignored? Or should this be
fixed like
rc = skcipher_walk_done(walk, nbytes - k);
if (rc) {
if (locked)
mutex_unlock(&ctrblk_lock);
goto out;
}
before the conversion?
Even though I said I don't want to fix pre-existing issues, I broke a
similar code path with the first patch, so...
next prev parent reply other threads:[~2026-08-04 12: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
2026-08-04 12:47 ` Heiko Carstens [this message]
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=20260804124705.12261Cbe-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=dengler@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
/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.