From: sashiko-bot@kernel.org
To: "Omar Elghoul" <oelghoul@linux.ibm.com>
Cc: "Heiko Carstens" <hca@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
linux-s390@vger.kernel.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v9 4/4] vfio-pci/zdev: Add VFIO FMB device features
Date: Wed, 07 Oct 2026 14:07:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-163087@kernel.org> (raw)
In-Reply-To: <20261007135926.82935-5-oelghoul@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] vfio_pci: NULL pointer deref in fmb_read on fmb allocation failure
- [High] vfio_pci: stack buffer overflow in fmb_read via unbounded fmb_length
--
commit 759143700fb3898fd78661e48f994eff036f8cf5
Author: Omar Elghoul <oelghoul@linux.ibm.com>
vfio-pci/zdev: Add VFIO FMB device features
This commit introduces new VFIO features for zPCI devices to provide FMB
passthrough to userspace. It allows enabling or disabling the FMB using a SET
feature, and reading the latest FMB using a GET feature.
> diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
> index f47f36314a1cc..1a66f455545ab 100644
> --- a/drivers/vfio/pci/vfio_pci_zdev.c
> +++ b/drivers/vfio/pci/vfio_pci_zdev.c
[ ... ]
> +int vfio_pci_zdev_feature_fmb_enable(struct vfio_pci_core_device *vdev, u32 flags,
> + void __user *arg, size_t argsz)
> +{
[ ... ]
> + if (fmb_enable.enabled) {
> + zdev->fmb_requested = true;
> + return zpci_fmb_reenable_device(zdev);
[Severity: High]
If zpci_fmb_reenable_device() fails (for example, if kmem_cache_zalloc()
returns -ENOMEM), does zdev->fmb_requested remain set to true?
Since the failure doesn't revert the flag to false, could this leave the
device state inconsistent for future FMB reads?
[Severity: High]
Is it intentional to bypass the zdev->fmb_length bounds check here?
The standard enablement path typically validates that zdev->fmb_length fits
within the structure boundaries. By calling zpci_fmb_reenable_device()
directly, it appears a hardware-supplied length greater than the size of
struct zpci_fmb could be accepted and saved.
> + }
> +
> + return zpci_fmb_disable_device(zdev);
> +}
> +
> +int vfio_pci_zdev_feature_fmb_read(struct vfio_pci_core_device *vdev, u32 flags,
> + void __user *arg, size_t argsz)
> +{
> + struct zpci_dev *zdev;
> + struct vfio_device_feature_zpci_fmb_read fmb_read;
> + struct zpci_fmb fmb_bounce;
[ ... ]
> + scoped_guard(mutex, &zdev->fmb_lock) {
> + if (!zdev->fmb_requested)
> + return -ENOMSG;
> + memcpy(&fmb_bounce, zdev->fmb, zdev->fmb_length);
[Severity: High]
If a previous call to vfio_pci_zdev_feature_fmb_enable() failed during
allocation but left zdev->fmb_requested = true, this check will pass.
Will this result in a NULL pointer dereference when accessing zdev->fmb in
this memcpy()?
[Severity: High]
Can zdev->fmb_length be larger than sizeof(struct zpci_fmb)?
If an oversized fmb_length is reported by the hardware or firmware and was not
validated during enablement, could copying up to that length into the
fixed-size local stack variable fmb_bounce result in a stack buffer overflow?
> + }
> +
> + if (copy_to_user(u64_to_user_ptr(fmb_read.data), &fmb_bounce, zdev->fmb_length))
> + return -EFAULT;
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261007135926.82935-1-oelghoul@linux.ibm.com?part=4
next prev parent reply other threads:[~2026-10-07 14:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 13:59 [PATCH v9 0/4] vfio-pci/zdev: Improved zPCI Function Measurement Support Omar Elghoul
2026-10-07 13:59 ` [PATCH v9 1/4] s390/pci: Hold fmb_lock when enabling or disabling PCI devices Omar Elghoul
2026-10-07 14:13 ` sashiko-bot
2026-10-07 13:59 ` [PATCH v9 2/4] s390/pci: Reuse FMB buffer and preserve state in device re-enablement Omar Elghoul
2026-10-07 14:11 ` sashiko-bot
2026-10-07 13:59 ` [PATCH v9 3/4] s390/pci: Fence FMB enable/disable via debugfs for passthrough devices Omar Elghoul
2026-10-07 14:06 ` sashiko-bot
2026-10-07 13:59 ` [PATCH v9 4/4] vfio-pci/zdev: Add VFIO FMB device features Omar Elghoul
2026-10-07 14:07 ` sashiko-bot [this message]
2026-10-07 14:24 ` Omar Elghoul
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=sashiko-outbox-163087@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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=oelghoul@linux.ibm.com \
--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