Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christoph Schlameuss" <schlameuss@linux.ibm.com>
Cc: "Alexander Gordeev" <agordeev@linux.ibm.com>,
	kvm@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.vom>
Subject: Re: [PATCH v4 20/20] KVM: s390: vsie: Enable use of VSIE SSCA
Date: Wed, 12 Aug 2026 17:45:56 +0000	[thread overview]
Message-ID: <20260812174556.B10CB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812-vsie-sigpi-v4-20-f19e49666315@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Guest-2 can trigger an out-of-bounds array access (both read and write) in host kernel memory by supplying a malicious `icpua` value.
- [High] The newly introduced VSIE SCA shadowing code contains multiple WARN_ON_ONCE assertions that can be triggered by a malicious guest, leading to a host kernel panic.
- [High] VSIE unconditionally allows nested guests to use SSCA (SIGPI and SRSI interpretation) if the host supports it, bypassing the guest-2's negotiated CPU model capabilities.
- [High] Guest-triggerable QEMU/VM abort via invalid or unaligned SCA entry addresses.
--

--- Patch [20]: [PATCH v4 20/20] KVM: s390: vsie: Enable use of VSIE SSCA ---
commit 3bbd1f1a442d7f9a9ee468b6c61e02cb8392ba96
Author: Christoph Schlameuss <schlameuss@linux.ibm.com>

KVM: s390: vsie: Enable use of VSIE SSCA

This commit enables code paths configuring and using VSIE SIGPI and SRSI.
It adds a new module parameter to globally disable SIGP, but defaults to
enabled on supported hardware to improve guest-3 performance.

> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index c21603f2745bf..59561d459a4f3 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c

[ ... ]

> @@ -477,6 +482,8 @@ static void __init kvm_s390_cpu_feat_init(void)
>  		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_KSS);
>  	if (sclp.has_astfleie2)
>  		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ASTFLEIE2);
> +	if (sclp.has_vsie_interp_extf && ssca)
> +		allow_cpu_feat(KVM_S390_VM_CPU_FEAT_SIGPIF);

[Severity: High]
Does this globally enable SSCA for the VM without verifying if the guest was
provisioned with the feature?

Looking at use_ssca() in arch/s390/kvm/vsie.c, it only checks the host-level
flag kvm->arch.use_ssca:

arch/s390/kvm/vsie.c:use_ssca() {
    if (!kvm->arch.use_ssca)
        return false;
    ...
}

Would this allow a nested guest to use SSCA features even if QEMU explicitly
disabled KVM_S390_VM_CPU_FEAT_SIGPIF for the CPU model, potentially breaking
capability negotiation and live migration?

[ ... ]

> @@ -3389,7 +3393,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
>  
>  	kvm->arch.use_pfmfi = sclp.has_pfmfi;
>  	kvm->arch.use_skf = sclp.has_skey;
> -	kvm->arch.use_ssca = sclp.has_vsie_interp_extf;
> +	kvm->arch.use_ssca = sclp.has_vsie_interp_extf && ssca;

[Severity: Critical]
Is there a potential out-of-bounds array access when validating the guest's
icpua index now that these paths are being used?

In kvm_s390_handle_vsie(), the bounds check compares scb_o->icpua against
KVM_S390_MAX_VSIE_VCPUS:

arch/s390/kvm/vsie.c:kvm_s390_handle_vsie() {
    if (scb_o->icpua >= KVM_S390_MAX_VSIE_VCPUS) {
        rc = kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
        goto out_unpin;
    }
    ...
}

Since icpua is a signed 16-bit integer, could a negative value bypass this
check?

Additionally, scb_o resides in guest memory. Is there a TOCTOU race where the
guest could change icpua after the check, before it is read again for the
array index in get_vsie_page_cpu_nr()?

arch/s390/kvm/vsie.c:get_vsie_page_cpu_nr() {
    ...
    vsie_page = vsie_sca->pages[cpu_nr];
    ...
    WRITE_ONCE(vsie_sca->pages[cpu_nr], vsie_page_new);
}

Could this lead to host memory corruption if an untrusted guest supplies a
malicious index?

[Severity: High]
Could enabling these code paths allow a guest to trigger host kernel panics
via WARN_ON_ONCE assertions?

For example, if a guest configures a nested guest with an unmapped SCA address,
pin_guest_pages() or pin_scb() would return a negative error code (like
-EFAULT). This error is assigned to sca_o_nr_pages and triggers a warning:

arch/s390/kvm/vsie.c:pin_sca() {
    ...
    if (WARN_ON_ONCE(vsie_sca->sca_o_nr_pages != nr_pages))
    ...
}

Similar warnings exist in get_vsie_page_cpu_nr() and get_vsie_page() when
vsie_page_init() fails. Since KVM guidelines advise against guest-reachable
WARN_ON assertions, should these be converted to avoid host Denial of Service?

[Severity: High]
Could this also allow a guest to crash the hypervisor by supplying invalid
nested SCB addresses?

In _shadow_sca(), if the guest provides an unaligned address, it returns
-EINVAL directly:

arch/s390/kvm/vsie.c:_shadow_sca() {
    if (scb_o_gpa & 0x1ffUL) {
        rc = -EINVAL;
        goto err;
    }
    ...
}

If the address is unmapped, get_vsie_page_cpu_nr() fails and returns -ENOMEM.
These error codes appear to propagate up to the main instruction intercept
handler. Will this cause KVM to exit to userspace with the error, aborting
the QEMU process instead of injecting an architectural program exception into
the guest?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812-vsie-sigpi-v4-0-f19e49666315@linux.ibm.com?part=20

      reply	other threads:[~2026-08-12 17:45 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 13:52 [PATCH v4 00/20] KVM: s390: vsie: Add VSIE SIGP ECALL and SRSI Interpretation Christoph Schlameuss
2026-08-12 13:52 ` [PATCH v4 01/20] KVM: s390: vsie: Add SCAO read and write helpers Christoph Schlameuss
2026-08-12 13:58   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 02/20] KVM: s390: vsie: Move SCAO validation into a function Christoph Schlameuss
2026-08-12 15:13   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 03/20] KVM: s390: vsie: Add vsie_interp_extf detection Christoph Schlameuss
2026-08-12 13:58   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 04/20] KVM: s390: vsie: Add ssca_block and ssca_entry structs Christoph Schlameuss
2026-08-12 13:57   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 05/20] KVM: s390: vsie: Move pin/unpin_scb methods Christoph Schlameuss
2026-08-12 14:03   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 06/20] KVM: s390: vsie: Move pin/unpin guest page Christoph Schlameuss
2026-08-12 14:08   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 07/20] KVM: s390: vsie: Move release/acquire gmap shadow Christoph Schlameuss
2026-08-12 14:02   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 08/20] KVM: s390: vsie: Create helpers to alloc and free vsie_pages Christoph Schlameuss
2026-08-12 14:04   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 09/20] KVM: s390: vsie: Replace radix_tree with xarray addr_to_page Christoph Schlameuss
2026-08-12 14:03   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 10/20] KVM: s390: vsie: Add helper to release gmap shadow Christoph Schlameuss
2026-08-12 14:04   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 11/20] KVM: s390: vsie: Lazily keep original scb pinned after vsie exit Christoph Schlameuss
2026-08-12 15:28   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 12/20] KVM: s390: vsie: Add helper to pin and unpin multiple guest pages Christoph Schlameuss
2026-08-12 14:11   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 13/20] KVM: s390: vsie: Add struct vsie_sca with pin and unpin methods Christoph Schlameuss
2026-08-12 15:43   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 14/20] KVM: s390: vsie: Shadow VSIE SCA in guest-1 Christoph Schlameuss
2026-08-12 16:10   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 15/20] KVM: s390: vsie: Guard against invalid CPU address Christoph Schlameuss
2026-08-12 16:23   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 16/20] KVM: s390: vsie: Allow guest-3 cpu add and remove with ssca Christoph Schlameuss
2026-08-12 16:40   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 17/20] KVM: s390: vsie: Add VSIE max shadow configuration Christoph Schlameuss
2026-08-12 16:53   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 18/20] KVM: s390: vsie: Add VSIE shadow stat counters Christoph Schlameuss
2026-08-12 17:02   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 19/20] KVM: s390: vsie: Create minimal scb shadows for not running g3 blocks Christoph Schlameuss
2026-08-12 17:26   ` sashiko-bot
2026-08-12 13:52 ` [PATCH v4 20/20] KVM: s390: vsie: Enable use of VSIE SSCA Christoph Schlameuss
2026-08-12 17:45   ` 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=20260812174556.B10CB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.vom \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=schlameuss@linux.ibm.com \
    /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