Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: kvmarm@lists.linux.dev, "Marc Zyngier" <maz@kernel.org>,
	"Oliver Upton" <oupton@kernel.org>
Subject: Re: [PATCH v3 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI
Date: Tue, 04 Aug 2026 11:40:56 +0000	[thread overview]
Message-ID: <20260804114056.922561F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804112317.1937387-11-fuad.tabba@linux.dev>

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

Pre-existing issues:
- [High] Missing context synchronization event (ISB) after writing to SYS_SCTLR.
- [High] Double-fetch of untrusted host memory in pkvm_refill_memcache() leading to a TOCTOU vulnerability.
--

--- Patch [10]: [PATCH v3 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI ---
commit c02cd7851991d5d8c9aac5af1e86684fe8258ca4
Author: Fuad Tabba <fuad.tabba@linux.dev>
KVM: arm64: nVHE: Check hypercall handlers against the declared ABI

This patch replaces manually unmarshalled hypercall arguments using
DECLARE_REG() with generated handlers via DEFINE_KVM_HOST_HCALL() and
DEFINE_KVM_HOST_HCALL0(). This ensures that the parameter list is type-checked
against the signature declared in <asm/kvm_hcall.h> to prevent mismatches
between caller and handler.

> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 23cb4313c60a2..675d607727929 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c

[ ... ]

>  static int pkvm_refill_memcache(struct pkvm_hyp_vcpu *hyp_vcpu)
>  {
>  	struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu;
>  
>  	return refill_memcache(&hyp_vcpu->vcpu.arch.pkvm_memcache,
>  			       host_vcpu->arch.pkvm_memcache.nr_pages,
>  			       &host_vcpu->arch.pkvm_memcache);
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
This is a pre-existing issue, but could this double-fetch of untrusted host
memory lead to a TOCTOU race condition?

The host memory is dereferenced here to read nr_pages and then passed as a
pointer to refill_memcache(), which fetches from it again:

arch/arm64/kvm/hyp/nvhe/mm.c:refill_memcache() {
    ...
    struct kvm_hyp_memcache tmp = *host_mc;
    ...
}

If the host concurrently modifies the struct between the fetches, EL2 might
use a min_pages target that differs from the actual struct state. Should the
struct be copied to EL2 private memory first before acting on it?

>  }

[ ... ]

> -static void handle___kvm_enable_ssbs(struct kvm_cpu_context *host_ctxt)
> +DEFINE_KVM_HOST_HCALL0(void, __kvm_enable_ssbs)
>  {
>  	u64 tmp;
>  
>  	tmp = read_sysreg_el2(SYS_SCTLR);
>  	tmp |= SCTLR_ELx_DSSBS;
>  	write_sysreg_el2(tmp, SYS_SCTLR);
>  }
   ^

[Severity: High]
This isn't a bug introduced by this patch, but should an isb() instruction be
issued after the write to SYS_SCTLR?

Updates to control-plane system registers like SYS_SCTLR require a Context
Synchronization Event (CSE) to be visible to subsequent instructions.
Returning without an immediate isb() might leave the processor operating with
an architecturally undefined pipeline state.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804112317.1937387-1-fuad.tabba@linux.dev?part=10

  reply	other threads:[~2026-08-04 11:40 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 11:23 [PATCH v3 00/11] KVM: arm64: Restore type-checking across the host/hyp hypercall boundary Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 01/11] tracing: Include linux/types.h in trace_remote_event.h Fuad Tabba
2026-08-05 20:54   ` Steven Rostedt
2026-08-06  8:43     ` Fuad Tabba
2026-08-06 12:19       ` Steven Rostedt
2026-08-06 12:35         ` Vincent Donnefort
2026-08-10 22:30   ` Steven Rostedt
2026-08-11 14:44     ` Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 02/11] KVM: arm64: nVHE: Share the stacktrace per-CPU declarations with EL2 Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 03/11] KVM: arm64: nVHE: Declare the hyp event IDs before defining them Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 04/11] KVM: arm64: nVHE: Use NULL to reset the trace buffer backing pointer Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 05/11] KVM: arm64: nVHE: Run the source checker under C=2 Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 06/11] arm64: pi: Run the source checker on the libfdt objects " Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 07/11] KVM: arm64: nVHE: Pass host VA arguments as pointers Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 08/11] KVM: arm64: Move the host hypercall interface to its own header Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 09/11] KVM: arm64: Type-check hypercall arguments at the caller Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 10/11] KVM: arm64: nVHE: Check hypercall handlers against the declared ABI Fuad Tabba
2026-08-04 11:40   ` sashiko-bot [this message]
2026-08-04 12:09     ` Fuad Tabba
2026-08-04 11:23 ` [PATCH v3 11/11] KVM: arm64: Tag host-VA hypercall parameters __kern Fuad Tabba
2026-08-06  9:17 ` [PATCH v3 00/11] KVM: arm64: Restore type-checking across the host/hyp hypercall boundary Marc Zyngier

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=20260804114056.922561F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fuad.tabba@linux.dev \
    --cc=kvmarm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=oupton@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