Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Harald Freudenberger" <freude@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH v3 2/2] s390/zcrypt: Close speculative mem read possibility
Date: Thu, 23 Jul 2026 10:34:48 +0000	[thread overview]
Message-ID: <20260723103448.878ED1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723095453.127322-3-freude@linux.ibm.com>

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

Pre-existing issues:
- [High] Authorization bypass for administrative CPRB requests via domain auto-selection.
- [Medium] Incomplete Spectre v1 mitigation for the user-controlled domain value.
--

--- Patch [2]: [PATCH v3 2/2] s390/zcrypt: Close speculative mem read possibility ---
commit 231c807d810ac3d48184d28be474dabc8e020aa9
Author: Harald Freudenberger <freude@linux.ibm.com>

s390/zcrypt: Close speculative mem read possibility

This commit attempts to fix a speculative execution vulnerability in the
s390 zcrypt driver. It adds an array_index_nospec() barrier for the domain
value during administrative CPRB processing to prevent potential
side-channel attacks.

> diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
> --- a/drivers/s390/crypto/zcrypt_api.c
> +++ b/drivers/s390/crypto/zcrypt_api.c
> @@ -879,12 +879,13 @@ static long _zcrypt_send_cprb(u32 xflags, struct ap_perms *perms,
>  
>  	if (perms != &ap_perms && domain < AP_DOMAINS) {

[Severity: High]
This is a pre-existing issue, but does this check allow an authorization bypass
for administrative requests if the user specifies AUTOSEL_DOM (0xFFFF) as the
domain?

If an administrative CPRB request uses AUTOSEL_DOM, the condition
`domain < AP_DOMAINS` evaluates to false, causing the code to skip the
`test_bit_inv(domain, perms->adm)` administrative permission validation
entirely.

Later in _zcrypt_send_cprb(), the queue selection logic autoselects a queue and
only validates the user's usage permissions via zcrypt_check_queue(). Does this
allow unprivileged users with access to a restricted custom device node to
execute administrative commands on a queue where they only have usage rights?

>  		if (ap_msg.flags & AP_MSG_FLAG_ADMIN) {
> +			domain = array_index_nospec(domain, AP_DOMAINS);
>  			if (!test_bit_inv(domain, perms->adm)) {
>  				rc = -ENODEV;
>  				goto out;
>  			}
>  		} else if ((ap_msg.flags & AP_MSG_FLAG_USAGE) == 0) {
>  			rc = -EOPNOTSUPP;
>  			goto out;
>  		}
>  	}
>  	/*
>  	 * If a valid target domain is set and this domain is NOT a usage
>  	 * domain but a control only domain, autoselect target domain.
>  	 */
>  	if (domain < AP_DOMAINS &&
>  	    !ap_test_config_usage_domain(domain) &&

[Severity: Medium]
This isn't a bug introduced by this patch, but does the un-sanitized domain
value remain vulnerable to speculative out-of-bounds reads here?

The patch adds array_index_nospec() inside the AP_MSG_FLAG_ADMIN check, but
for non-administrative requests, the domain variable is used unmitigated in
ap_test_config_usage_domain() and ap_test_config_ctrl_domain().

Both functions call into ap_test_config(), which uses the domain as an array
index. Since the `domain < AP_DOMAINS` bounds check can be speculatively
bypassed, does this leave a Prime+Probe side-channel attack gadget open for
non-administrative requests?

>  	    ap_test_config_ctrl_domain(domain))
>  		domain = AUTOSEL_DOM;

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

      reply	other threads:[~2026-07-23 10:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  9:54 [PATCH v3 0/2] Fixes related to domain access and verification Harald Freudenberger
2026-07-23  9:54 ` [PATCH v3 1/2] s390/zcrypt: Fix wrong domain value verification with EP11 CPRBs Harald Freudenberger
2026-07-23 10:15   ` sashiko-bot
2026-07-23  9:54 ` [PATCH v3 2/2] s390/zcrypt: Close speculative mem read possibility Harald Freudenberger
2026-07-23 10:34   ` sashiko-bot [this message]

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=20260723103448.878ED1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@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