From: sashiko-bot@kernel.org
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] vfio: cdev: Reject duplicate bind before updating KVM file
Date: Thu, 01 Oct 2026 09:45:07 +0000 [thread overview]
Message-ID: <20261001094507.B2BAF1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001093152.1698474-1-aneesh.kumar@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] vfio: UAPI breakage returning -EINVAL instead of -EBUSY on duplicate bind
--
commit c22368f571a5e2ac9cc22bf312688fe247d99cd9
Author: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
vfio: cdev: Reject duplicate bind before updating KVM file
This commit prevents a second file descriptor for the same device from
overwriting the KVM reference. It does this by checking device->open_count
earlier during the bind operation.
> diff --git a/drivers/vfio/device_cdev.c b/drivers/vfio/device_cdev.c
> index 30362936c7b59..0f23ccb780e05 100644
> --- a/drivers/vfio/device_cdev.c
> +++ b/drivers/vfio/device_cdev.c
> @@ -124,8 +124,8 @@ long vfio_df_ioctl_bind_iommufd(struct vfio_device_file *df,
> return ret;
>
> mutex_lock(&device->dev_set->lock);
> - /* one device cannot be bound twice */
> - if (df->access_granted) {
> + /* The cdev path only supports one bound/open device fd. */
> + if (df->access_granted || device->open_count) {
> ret = -EINVAL;
> goto out_unlock;
> }
[Severity: High]
Does this change unintentionally alter the UAPI by returning -EINVAL instead
of -EBUSY when device->open_count is non-zero?
Further down in drivers/vfio/device_cdev.c:vfio_df_ioctl_bind_iommufd(),
there is an explicit check intended to handle transient opens:
if (device->open_count) {
ret = -EBUSY;
goto out_unlock;
}
By checking device->open_count in the first conditional block and returning
-EINVAL, the second block returning -EBUSY becomes dead code. Will this
cause applications relying on -EBUSY to trigger a retry to fail unexpectedly?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001093152.1698474-1-aneesh.kumar@kernel.org?part=1
next prev parent reply other threads:[~2026-10-01 9:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 9:31 [PATCH] vfio: cdev: Reject duplicate bind before updating KVM file Aneesh Kumar K.V (Arm)
2026-10-01 9:45 ` sashiko-bot [this message]
2026-10-01 14:12 ` Alex Williamson
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=20261001094507.B2BAF1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aneesh.kumar@kernel.org \
--cc=kvm@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