public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: "Gupta, Nipun" <nipun.gupta@amd.com>
Cc: Prasanna Kumar T S M <ptsm@linux.microsoft.com>,
	nikhil.agarwal@amd.com, pieter.jansen-van-vuuren@amd.com,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, alex@shazbot.org
Subject: Re: [PATCH 1/2] vfio/cdx: Fix NULL pointer dereference in interrupt trigger path
Date: Wed, 1 Apr 2026 12:22:54 -0600	[thread overview]
Message-ID: <20260401122254.363d93c2@shazbot.org> (raw)
In-Reply-To: <e9f01579-fd53-50b9-996b-cd1d3342f453@amd.com>

On Wed, 1 Apr 2026 15:11:17 +0530
"Gupta, Nipun" <nipun.gupta@amd.com> wrote:

> On 20-03-2026 15:49, Prasanna Kumar T S M wrote:
> > Add validation to ensure MSI is configured before accessing cdx_irqs
> > array in vfio_cdx_set_msi_trigger(). Without this check, userspace
> > can trigger a NULL pointer dereference by calling VFIO_DEVICE_SET_IRQS
> > with VFIO_IRQ_SET_DATA_BOOL or VFIO_IRQ_SET_DATA_NONE flags before
> > ever setting up interrupts via VFIO_IRQ_SET_DATA_EVENTFD.
> > 
> > The vfio_cdx_msi_enable() function allocates the cdx_irqs array and
> > sets config_msi to 1 only when called through the EVENTFD path. The
> > trigger loop (for DATA_BOOL/DATA_NONE) assumed this had already been
> > done, but there was no enforcement of this call ordering.
> > 
> > This matches the protection used in the PCI VFIO driver where
> > vfio_pci_set_msi_trigger() checks irq_is() before the trigger loop.
> > 
> > Fixes: 848e447e000c ("vfio/cdx: add interrupt support")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>  
> 
> Acked-by: Nipun Gupta <nipun.gupta@amd.com>

It's an improvement, but I think it also highlights that interrupt
setup for vfio-cdx devices is racy.  I think it should adopt a mutex on
the vfio_cdx_device that is acquired with a guard in
vfio_cdx_set_irqs_ioctl().  That would make config_msi stable for this
test.  Thanks,

Alex


  reply	other threads:[~2026-04-01 18:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 10:19 [PATCH 1/2] vfio/cdx: Fix NULL pointer dereference in interrupt trigger path Prasanna Kumar T S M
2026-03-20 10:21 ` [PATCH 2/2] cdx: Fix double free when sysfs file creation fails Prasanna Kumar T S M
2026-04-01  9:42   ` Gupta, Nipun
2026-04-01  9:41 ` [PATCH 1/2] vfio/cdx: Fix NULL pointer dereference in interrupt trigger path Gupta, Nipun
2026-04-01 18:22   ` Alex Williamson [this message]
2026-04-02  4:44     ` Prasanna Kumar T S M
2026-04-02 14:16       ` Alex Williamson
2026-04-06  4:18         ` Prasanna Kumar T S M

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=20260401122254.363d93c2@shazbot.org \
    --to=alex@shazbot.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nikhil.agarwal@amd.com \
    --cc=nipun.gupta@amd.com \
    --cc=pieter.jansen-van-vuuren@amd.com \
    --cc=ptsm@linux.microsoft.com \
    --cc=stable@vger.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