Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Mostafa Saleh <smostafa@google.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, tglx@kernel.org
Subject: Re: [PATCH] irqchip/gic-v4: Harden against bogus command line
Date: Tue, 26 May 2026 10:45:14 +0100	[thread overview]
Message-ID: <86wlwqv711.wl-maz@kernel.org> (raw)
In-Reply-To: <ahVQtakwshwI9ss-@google.com>

On Tue, 26 May 2026 08:50:13 +0100,
Mostafa Saleh <smostafa@google.com> wrote:
> 
> On Sat, May 23, 2026 at 10:53:23AM +0100, Marc Zyngier wrote:
> > On Thu, 21 May 2026 14:05:03 +0100,
> > Mostafa Saleh <smostafa@google.com> wrote:
> > > 
> > > When accidentally setting “kvm-arm.vgic_v4_enable=1” on the wrong
> > > setup that has no MSI controller device tree node (it exists but
> > > not used) and GICv4, it caused a panic as “gic_domain” is NULL and
> > > the kernel attempted to access its ops.
> > 
> > When you say "that has no MSI controller device tree node", does it
> > mean that the ITS has not been probed at all?
> 
> Yes.
> 
> > 
> > >
> > > Originally, I hit this on an older kernel, but was able to reproduce
> > > it on upstream with Qemu by hacking this unreasonable setup.
> > > 
> > > [   33.145536] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000028
> > > [   33.145658] Mem abort info:
> > > [   33.145751]   ESR = 0x0000000096000006
> > > ...
> > > [   33.154057] CPU: 1 UID: 0 PID: 295 Comm: lkvm-static Not tainted 7.1.0-rc4-ge3f15ad3970e #5 PREEMPT
> > > [   33.156922] Hardware name: linux,dummy-virt (DT)
> > > [   33.158780] pstate: 81402005 (Nzcv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
> > > [   33.160340] pc : __irq_domain_instantiate+0x1d4/0x578
> > > [   33.162602] lr : __irq_domain_instantiate+0x1cc/0x578
> > > 
> > > Add a hardening check to avoid the NULL access, and fail the VM
> > > creation in that case.
> > > 
> > > Signed-off-by: Mostafa Saleh <smostafa@google.com>
> > > ---
> > >  drivers/irqchip/irq-gic-v4.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c
> > > index 8455b4a5fbb0..7e39f7eae85f 100644
> > > --- a/drivers/irqchip/irq-gic-v4.c
> > > +++ b/drivers/irqchip/irq-gic-v4.c
> > > @@ -159,6 +159,9 @@ int its_alloc_vcpu_irqs(struct its_vm *vm)
> > >  {
> > >  	int vpe_base_irq, i;
> > >  
> > > +	if (!gic_domain)
> > > +		return -EINVAL;
> > > +
> > >  	vm->fwnode = irq_domain_alloc_named_id_fwnode("GICv4-vpe",
> > >  						      task_pid_nr(current));
> > >  	if (!vm->fwnode)
> > 
> > I think this check is a good few levels too late. If you want to fix
> > this, I'd rather make sure that kvm_vgic_global_state.has_gicv4 is
> > reliable and covers this case. Which means making sure that
> > gic_kvm_info::has_v4 is itself reliable.
> > 
> > If my above understanding is correct, I'd expect the following
> > (untested) hack to help.
> 
> Thanks! That also fixes the crash, the VM will launch with a vGIC with
> no ITS in that case.

You should still be able to have a virtual ITS, just no direct
injection of any sort.

If you're happy with that, please respin a patch with this hack.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2026-05-26  9:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 13:05 [PATCH] irqchip/gic-v4: Harden against bogus command line Mostafa Saleh
2026-05-23  9:53 ` Marc Zyngier
2026-05-26  7:50   ` Mostafa Saleh
2026-05-26  9:45     ` Marc Zyngier [this message]
2026-05-26 11:33       ` Mostafa Saleh

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=86wlwqv711.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=smostafa@google.com \
    --cc=tglx@kernel.org \
    /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