Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anthony Krowiak" <akrowiak@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	kvm@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>
Subject: Re: [PATCH v7 2/6] s390/vfio-ap: Fix failure to release IRQ notification eventfd contexts
Date: Fri, 04 Sep 2026 22:49:04 +0000	[thread overview]
Message-ID: <20260904224904.A8DE31F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904223531.1611088-3-akrowiak@linux.ibm.com>

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

Pre-existing issues:
- [High] Out-of-bounds read of user memory and logic error in `vfio_ap_set_request_irq` and `vfio_ap_set_cfg_change_irq`.
--

commit 771c755d8bf563861fa80183f68a6dbe8966844c
Author: Anthony Krowiak <akrowiak@linux.ibm.com>

    s390/vfio-ap: Fix failure to release IRQ notification eventfd contexts
    
    When userspace registers IRQ notification eventfds via the
    VFIO_DEVICE_SET_IRQS ioctl, vfio_ap_set_request_irq() and
    vfio_ap_set_cfg_change_irq() each call eventfd_ctx_fdget(), which
    takes a reference on the eventfd_ctx and stores it. These references
    are dropped only when userspace explicitly replaces or clears them,
    causing a leak if the device is closed without explicit teardown. This
    commit fixes the leak by introducing vfio_ap_mdev_release_eventfds()
    to clean up the references during close_device().

> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 9d4f5b9e3301f..4a31454d725a9 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c

[ ... ]

This isn't a bug introduced by this patch, but I noticed a pre-existing issue
in vfio_ap_set_request_irq() and vfio_ap_set_cfg_change_irq().

If a userspace process issues the VFIO_DEVICE_SET_IRQS ioctl with count == 0
and DATA_EVENTFD to clear the IRQ, could this unconditionally read out of
bounds?

drivers/s390/crypto/vfio_ap_ops.c:vfio_ap_set_request_irq() {
	s32 fd;
	void __user *data;
	unsigned long minsz;
...
	minsz = offsetofend(struct vfio_irq_set, count);
	data = (void __user *)(arg + minsz);

	if (get_user(fd, (s32 __user *)data))
		return -EFAULT;
...
}

[Severity: High]
Does this code read past the user-provided struct vfio_irq_set buffer if
count is 0?

Because there is no check for count > 0 before doing get_user(), it appears
this reads 4 bytes past the user-provided buffer and interprets the
uninitialized data as a file descriptor instead of safely disabling the
interrupt.

The same pattern appears in vfio_ap_set_cfg_change_irq():

drivers/s390/crypto/vfio_ap_ops.c:vfio_ap_set_cfg_change_irq() {
	s32 fd;
	void __user *data;
	unsigned long minsz;
...
	minsz = offsetofend(struct vfio_irq_set, count);
	data = (void __user *)(arg + minsz);

	if (get_user(fd, (s32 __user *)data))
		return -EFAULT;
...
}

[Severity: High]
Does this code also have the same out-of-bounds read issue when count is 0?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904223531.1611088-1-akrowiak@linux.ibm.com?part=2

  reply	other threads:[~2026-09-04 22:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 22:35 [PATCH v7 0/6] s390/vfio-ap: Fix pre-existing bugs in vfio_ap device driver Anthony Krowiak
2026-09-04 22:35 ` [PATCH v7 1/6] s390/vfio-ap: Fix leaks of pinned NIB and registered GISC Anthony Krowiak
2026-09-04 22:51   ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 2/6] s390/vfio-ap: Fix failure to release IRQ notification eventfd contexts Anthony Krowiak
2026-09-04 22:49   ` sashiko-bot [this message]
2026-09-04 22:35 ` [PATCH v7 3/6] s390/vfio-ap: Fix unbounded loop in apq_reset_check() Anthony Krowiak
2026-09-04 22:49   ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 4/6] s390/vfio-ap: Use AP_DOMAINS for adm_add bitmap size in vfio_ap_mdev_cfg_add() Anthony Krowiak
2026-09-04 22:46   ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 5/6] s390/vfio-ap: fix queue state leakage to guest and host Anthony Krowiak
2026-09-04 22:46   ` sashiko-bot
2026-09-04 22:35 ` [PATCH v7 6/6] s390/vfio-ap: replace guest-reachable WARNs with ratelimited warnings and add dmesg visibility to DBF_WARNs Anthony Krowiak
2026-09-04 22:50   ` sashiko-bot

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=20260904224904.A8DE31F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.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