All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v5 4/5] iommufd/tsm: add vdevice TSM bind/unbind ioctl
Date: Mon, 25 May 2026 21:44:59 +0000	[thread overview]
Message-ID: <20260525214500.8A5871F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260525154816.1029642-5-aneesh.kumar@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Silent truncation of `virt_id` from 64-bit to 32-bit when calling `pci_tsm_bind`.
--

commit b7dc3508d5fe2b83fd395c4d50b0951a9d3d243b
Author: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>

iommufd/tsm: add vdevice TSM bind/unbind ioctl

Introduce IOMMU_VDEVICE_TSM_OP to allow userspace to issue TSM bind/unbind
operations for an iommufd vdevice. Also add common TSM helpers in tsm-core
and wire vdevice teardown to unbind the device from TSM state.

> diff --git a/drivers/virt/coco/tsm-core.c b/drivers/virt/coco/tsm-core.c
> index e784993353d8f..3870d08ffe0d1 100644
> --- a/drivers/virt/coco/tsm-core.c
> +++ b/drivers/virt/coco/tsm-core.c
[ ... ]
> @@ -108,6 +108,25 @@ void tsm_unregister(struct tsm_dev *tsm_dev)
>  }
>  EXPORT_SYMBOL_GPL(tsm_unregister);
>  
> +int tsm_bind(struct device *dev, struct kvm *kvm, u64 tdi_id)
> +{
> +	if (!dev_is_pci(dev))
> +		return -EINVAL;
> +
> +	return pci_tsm_bind(to_pci_dev(dev), kvm, tdi_id);

[Severity: Medium]
Does this cause a silent truncation of the virtual ID?

While tsm_bind accepts a u64 tdi_id, it passes this argument directly to
pci_tsm_bind, which expects a u32 tdi_id.

Because iommufd_vdevice_alloc_ioctl allows userspace to supply a 64-bit
virt_id, passing a value larger than 32 bits here will result in a truncated,
incorrect virtual device ID being registered with the TSM layer.

Could this lead to state inconsistency between iommufd and the TSM subsystem?

> +}
> +EXPORT_SYMBOL_GPL(tsm_bind);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260525154816.1029642-1-aneesh.kumar@kernel.org?part=4

  reply	other threads:[~2026-05-25 21:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25 15:48 [PATCH v5 0/5] Add iommufd ioctls to support TSM operations Aneesh Kumar K.V (Arm)
2026-05-25 15:48 ` [PATCH v5 1/5] vfio: cache KVM VM file references instead of raw struct kvm pointers Aneesh Kumar K.V (Arm)
2026-05-25 16:47   ` sashiko-bot
2026-05-26  8:11     ` Aneesh Kumar K.V
2026-05-26 10:52   ` Anthony Krowiak
2026-05-25 15:48 ` [PATCH v5 2/5] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-05-25 20:33   ` sashiko-bot
2026-05-26  8:17     ` Aneesh Kumar K.V
2026-05-25 15:48 ` [PATCH v5 3/5] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-05-25 15:48 ` [PATCH v5 4/5] iommufd/tsm: add vdevice TSM bind/unbind ioctl Aneesh Kumar K.V (Arm)
2026-05-25 21:44   ` sashiko-bot [this message]
2026-05-25 15:48 ` [PATCH v5 5/5] iommufd/vdevice: add TSM request ioctl Aneesh Kumar K.V (Arm)
2026-05-25 22:18   ` sashiko-bot
2026-05-26  8:18     ` Aneesh Kumar K.V
2026-05-27  0:16   ` Alexey Kardashevskiy
2026-05-27  6:17     ` Dan Williams (nvidia)
2026-05-27  6:56       ` Tian, Kevin
2026-05-27 12:51       ` Jason Gunthorpe
2026-05-27 15:34       ` Aneesh Kumar K.V
2026-05-27 17:49         ` Aneesh Kumar K.V
2026-05-27 22:49           ` Dan Williams (nvidia)
2026-06-02  5:10             ` Aneesh Kumar K.V
2026-06-08 20:58               ` Dan Williams (nvidia)
2026-06-09  8:59                 ` Aneesh Kumar K.V
2026-06-09 10:49                 ` Alexey Kardashevskiy
2026-06-02  8:40       ` Alexey Kardashevskiy

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=20260525214500.8A5871F000E9@smtp.kernel.org \
    --to=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.