From: sashiko-bot@kernel.org
To: "Omar Elghoul" <oelghoul@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v4 4/4] s390/pci: Fence FMB enable/disable via sysfs for passthrough devices
Date: Fri, 12 Jun 2026 18:22:52 +0000 [thread overview]
Message-ID: <20260612182252.AAE141F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612181048.91548-5-oelghoul@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch explicitly wraps a sleepable user-space memory copy (`kstrtoul_from_user()`) inside `mutex_lock(&zdev->kzdev_lock)`, introducing a lock-holding anti-pattern that can block system paths.
--
commit 0ba1ddb8db696b6bb98d1631644717f3b52b557c
Author: Omar Elghoul <oelghoul@linux.ibm.com>
s390/pci: Fence FMB enable/disable via sysfs for passthrough devices
This commit introduces a fence over enabling or disabling FMB via sysfs when
the zPCI device is associated with a KVM guest. This prevents the host from
disabling FMB while the guest is using it, securing the VM state.
> diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c
> --- a/arch/s390/pci/pci_debug.c
> +++ b/arch/s390/pci/pci_debug.c
> @@ -149,9 +149,15 @@ static ssize_t pci_perf_seq_write(struct file *file, const char __user *ubuf,
> if (!zdev)
> return 0;
>
> + mutex_lock(&zdev->kzdev_lock);
> + if (zdev->kzdev) {
> + rc = -EPERM;
> + goto out_unlock_kzdev;
> + }
> +
> rc = kstrtoul_from_user(ubuf, count, 10, &val);
[Severity: Medium]
Is it necessary to hold kzdev_lock while copying from user-space?
Calling kstrtoul_from_user() here means we are holding the kzdev_lock mutex
during a potentially blocking memory copy. If the user-space read blocks, it
will indefinitely hold kzdev_lock, stalling any other operations
synchronizing on this device's lock.
Since kstrtoul_from_user() only parses data into a local stack variable and
does not depend on the device state, does it make sense to move this call
before acquiring kzdev_lock?
> if (rc)
> - return rc;
> + goto out_unlock_kzdev;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612181048.91548-1-oelghoul@linux.ibm.com?part=4
prev parent reply other threads:[~2026-06-12 18:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 18:10 [PATCH v4 0/4] vfio-pci/zdev: Improved zPCI Function Measurement Support Omar Elghoul
2026-06-12 18:10 ` [PATCH v4 1/4] s390/pci: Hold fmb_lock when enabling or disabling PCI devices Omar Elghoul
2026-06-12 18:28 ` sashiko-bot
2026-06-12 18:10 ` [PATCH v4 2/4] s390/pci: Preserve FMB state in device re-enablement Omar Elghoul
2026-06-12 18:26 ` sashiko-bot
2026-06-12 18:10 ` [PATCH v4 3/4] vfio-pci/zdev: Add VFIO FMB device features Omar Elghoul
2026-06-12 18:28 ` sashiko-bot
2026-06-12 18:10 ` [PATCH v4 4/4] s390/pci: Fence FMB enable/disable via sysfs for passthrough devices Omar Elghoul
2026-06-12 18:22 ` sashiko-bot [this message]
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=20260612182252.AAE141F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@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