Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH v7 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm
Date: Mon, 31 Aug 2026 09:10:10 +0000	[thread overview]
Message-ID: <20260831091010.F02E51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831083838.3703-3-freude@linux.ibm.com>

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

Pre-existing issues:
- [Medium] Incomplete Fix / Data Exposure: The patch fixes a missing scrub of the `buf` temporary buffer in `ctr_paes_do_crypt()` to prevent data exposure, but misses the exact same vulnerability in `ctr_aes_crypt()` within `arch/s390/crypto/aes_s390.c`.
--

commit 40d179d4c1cbb2f9d3b0a3104c9a0096f37f307f
Author: Harald Freudenberger <freude@linux.ibm.com>

s390/crypto: Fix missing scrub of temp buffers with PAES algorithm

This commit addresses a missing scrub of temporary buffers in the PAES crypto 
algorithm. It zeroes out the processing buffer in ctr_paes_do_crypt() and 
ensures the entire parameter block is scrubbed in __xts_2keys_prep_param() to 
avoid exposing sensitive data.

> diff --git a/arch/s390/crypto/paes_s390.c b/arch/s390/crypto/paes_s390.c
> index ccc7da106c3a0..d075b0241f1f5 100644
> --- a/arch/s390/crypto/paes_s390.c
> +++ b/arch/s390/crypto/paes_s390.c
> @@ -1044,6 +1044,7 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
>  	}
>  
>  out:
> +	memzero_explicit(buf, sizeof(buf));
>  	pr_debug("rc=%d\n", rc);
>  	return rc;
>  }

[Severity: Medium]
This isn't a bug introduced by this patch, but while fixing the missing scrub
for PAES here, does the exact same vulnerability exist for standard AES in
arch/s390/crypto/aes_s390.c?

Looking at ctr_aes_crypt() in that file, it similarly uses a local stack 
buffer buf to process partial CTR blocks:

arch/s390/crypto/aes_s390.c:ctr_aes_crypt() {
        ...
        u8 buf[AES_BLOCK_SIZE], *ctrptr;
        ...
        if (nbytes) {
                memset(buf, 0, AES_BLOCK_SIZE);
                memcpy(buf, walk.src.virt.addr, nbytes);
                cpacf_kmctr(sctx->fc, sctx->key, buf, buf,
                            AES_BLOCK_SIZE, walk.iv);
                memcpy(walk.dst.virt.addr, buf, nbytes);
                ...
        }

        return ret;
}

This buffer holds sensitive payload data but returns without being scrubbed via
memzero_explicit(). Could this leave cryptographic data on the kernel stack
where it could be exposed if stack memory is later leaked? Should this same fix
be applied to standard AES as well?

[ ... ]

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

  reply	other threads:[~2026-08-31  9:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31  8:38 [PATCH v7 0/9] Fixes and rework for paes_s390 and phmac_s390 Harald Freudenberger
2026-08-31  8:38 ` [PATCH v7 1/9] s390/crypto: Fix return code handling at skcipher_walk_done in PAES algorithms Harald Freudenberger
2026-08-31  8:55   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 2/9] s390/crypto: Fix missing scrub of temp buffers with PAES algorithm Harald Freudenberger
2026-08-31  9:10   ` sashiko-bot [this message]
2026-08-31  8:38 ` [PATCH v7 3/9] s390/crypto: Fix use of mutex in atomic context in PAES Harald Freudenberger
2026-08-31  9:19   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 4/9] s390/crypto: Fix missing cra_flags in paes_s390 Harald Freudenberger
2026-08-31  9:32   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 5/9] s390/crypto: Fix handling of EBUSY in PAES when req is pushed to crypto engine Harald Freudenberger
2026-08-31  9:45   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 6/9] s390/crypto: Fix handling of EBUSY in PHMAC " Harald Freudenberger
2026-08-31  9:58   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 7/9] s390/crypto: Fix wrong return code to engine in asynch callbacks Harald Freudenberger
2026-08-31 10:04   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 8/9] s390/crypto: Map EBUSY to EIO when key conversion fails repeatedly Harald Freudenberger
2026-08-31 10:10   ` sashiko-bot
2026-08-31  8:38 ` [PATCH v7 9/9] s390/crypto: Enable CONTEXT_ANALYSIS Harald Freudenberger
2026-08-31 10:11   ` 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=20260831091010.F02E51F000E9@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