From: sashiko-bot@kernel.org
To: "Fuad Tabba" <fuad.tabba@linux.dev>
Cc: kvmarm@lists.linux.dev, "Oliver Upton" <oupton@kernel.org>,
"Marc Zyngier" <maz@kernel.org>
Subject: Re: [PATCH 1/3] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them
Date: Thu, 20 Aug 2026 13:06:15 +0000 [thread overview]
Message-ID: <20260820130616.1A7241F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260820125053.2951078-2-fuad.tabba@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a massive leak of IRQ descriptors and domains, leading to a Use-After-Free, caused by KVM truncating `vm->nr_vpes` in `vgic_v4_init()`.
--
--- Patch [1]: [PATCH 1/3] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them ---
commit c349510ce4924473f4dc4c6ff4ff6a9d4b983dd5
Author: Fuad Tabba <fuad.tabba@linux.dev>
irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them
The GICv4 allocation and teardown paths free their irq domains and
fwnodes but leave the pointers set, and the allocation error paths test
those pointers before removing them. struct its_vm and struct its_vpe
are embedded in KVM's per-VM and per-vCPU state, so nothing re-zeroes
them between two attempts.
> diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
> index 8455b4a5fbb0d..754839e409f88 100644
> --- a/drivers/irqchip/irq-gic-v4.c
> +++ b/drivers/irqchip/irq-gic-v4.c
[ ... ]
> @@ -224,6 +234,8 @@ void its_free_vcpu_irqs(struct its_vm *vm)
> irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes);
> irq_domain_remove(vm->domain);
> irq_domain_free_fwnode(vm->fwnode);
> + vm->domain = NULL;
> + vm->fwnode = NULL;
> }
[Severity: High]
This is a pre-existing issue, but does this function permanently leak IRQs
and SGI domains?
In arch/arm64/kvm/vgic/vgic-v4.c:vgic_v4_init(), KVM intentionally truncates
dist->its_vm.nr_vpes upon failure to allocate VPE IRQs:
dist->its_vm.nr_vpes = i;
This limits the teardown loop in vgic_v4_teardown(), which later calls
its_free_vcpu_irqs() with the fatally truncated nr_vpes value.
Because its_free_vcpu_irqs() relies on vm->nr_vpes to free the IRQ hierarchy
and SGI domains originally allocated for all VCPUs, the truncation causes a
partial free.
Furthermore, the parent IRQ domain is forcefully removed while still having
active IRQ mappings. Could this lead to a Use-After-Free of the domain memory
when those orphaned IRQ descriptors are accessed (e.g. via /proc/interrupts)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260820125053.2951078-1-fuad.tabba@linux.dev?part=1
next prev parent reply other threads:[~2026-08-20 13:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 12:50 [PATCH 0/3] irqchip/gic-v4, KVM: arm64: Fix the vgic init error paths Fuad Tabba
2026-08-20 12:50 ` [PATCH 1/3] irqchip/gic-v4: Clear the domain and fwnode pointers after freeing them Fuad Tabba
2026-08-20 13:06 ` sashiko-bot [this message]
2026-08-20 14:11 ` Fuad Tabba
2026-08-23 9:46 ` Marc Zyngier
2026-08-23 13:59 ` Fuad Tabba
2026-08-20 12:50 ` [PATCH 2/3] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Fuad Tabba
2026-08-20 13:03 ` sashiko-bot
2026-08-20 14:13 ` Fuad Tabba
2026-08-20 12:50 ` [PATCH 3/3] KVM: arm64: vgic: Tear down what vgic_init() created when it fails Fuad Tabba
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=20260820130616.1A7241F000E9@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