Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Joey Gouly <joey.gouly@arm.com>
To: Sascha Bischoff <Sascha.Bischoff@arm.com>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>, nd <nd@arm.com>,
	"maz@kernel.org" <maz@kernel.org>,
	"oupton@kernel.org" <oupton@kernel.org>,
	Suzuki Poulose <Suzuki.Poulose@arm.com>,
	"yuzenghui@huawei.com" <yuzenghui@huawei.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>
Subject: Re: [PATCH v2 4/4] KVM: arm64: Validate GICv5 timer PPIs before claiming ownership
Date: Wed, 12 Aug 2026 13:53:43 +0100	[thread overview]
Message-ID: <anxs1yj3Qbv2JkTf@e143914.arm.com> (raw)
In-Reply-To: <20260811150941.941295-5-sascha.bischoff@arm.com>

On Tue, Aug 11, 2026 at 03:11:48PM +0000, Sascha Bischoff wrote:
> With GICv5, timer PPIs use architecturally defined IDs, and therefore
> we require userspace to use the architected IDs too. We perform this
> validation in timer_irqs_are_valid(), which validates the configured
> PPI after claiming it with kvm_vgic_set_owner(). This is obviously the
> wrong order, and could both result in a NULL pointer dereference for
> an ID >= 64 and in an incorrect ownership claim.
> 
> Switch the order to first validate the PPI before setting the
> owner. This both prevents an invalid GICv5 timer PPI from reaching the
> IRQ lookup, and avoids claiming an IRQ for a timer configuration that
> will be rejected.
> 
> Fixes: 06c85b58e0b1 ("KVM: arm64: Move GICv5 timer PPI validation into timer_irqs_are_valid()")
> Link: https://sashiko.dev/#/message/20260810111614.DDC731F000E9%40smtp.kernel.org
> Signed-off-by: Sascha Bischoff <sascha.bischoff@arm.com>
> ---
>  arch/arm64/kvm/arch_timer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
> index 4155fe89b58a1..af7e2894cd690 100644
> --- a/arch/arm64/kvm/arch_timer.c
> +++ b/arch/arm64/kvm/arch_timer.c
> @@ -1529,13 +1529,14 @@ static bool timer_irqs_are_valid(struct kvm_vcpu *vcpu)
>  
>  		ctx = vcpu_get_timer(vcpu, i);
>  		irq = timer_irq(ctx);
> -		if (kvm_vgic_set_owner(vcpu, irq, ctx))
> -			break;
>  
>  		/* With GICv5, the default PPI is what you get -- nothing else */
>  		if (vgic_is_v5(vcpu->kvm) && irq != get_vgic_ppi(vcpu->kvm, default_ppi[i]))
>  			break;
>  
> +		if (kvm_vgic_set_owner(vcpu, irq, ctx))
> +			break;
> +
>  		/*
>  		 * We know by construction that we only have PPIs, so all values
>  		 * are less than 32 for non-GICv5 VGICs. On GICv5, they are

Reviewed-by: Joey Gouly <joey.gouly@arm.com>

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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 15:09 [PATCH v2 0/4] KVM: arm64: GICv5 KVM IRS review fixes Sascha Bischoff
2026-08-11 15:10 ` [PATCH v2 1/4] KVM: arm64: vgic: Free gic_kvm_info on initialization failure Sascha Bischoff
2026-08-12 13:14   ` Joey Gouly
2026-08-11 15:10 ` [PATCH v2 2/4] KVM: arm64: vgic: Prevent speculative SPI array underflow Sascha Bischoff
2026-08-12 13:43   ` Joey Gouly
2026-08-11 15:11 ` [PATCH v2 3/4] KVM: arm64: vgic: Reject out-of-range GICv5 PPI IDs Sascha Bischoff
2026-08-12 12:56   ` Joey Gouly
2026-08-11 15:11 ` [PATCH v2 4/4] KVM: arm64: Validate GICv5 timer PPIs before claiming ownership Sascha Bischoff
2026-08-12 12:53   ` Joey Gouly [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=anxs1yj3Qbv2JkTf@e143914.arm.com \
    --to=joey.gouly@arm.com \
    --cc=Sascha.Bischoff@arm.com \
    --cc=Suzuki.Poulose@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=maz@kernel.org \
    --cc=nd@arm.com \
    --cc=oupton@kernel.org \
    --cc=yuzenghui@huawei.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