All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files
@ 2026-12-02  1:14 chenglong ma
  2026-12-02  1:15 ` [PATCH v4 2/2] vduse: don't set VM_IO on the domain file mapping chenglong ma
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: chenglong ma @ 2026-12-02  1:14 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Jason Wang, Eugenio Pérez, Xuan Zhuo, Lorenzo Stoakes (ARM),
	Xie Yongji, virtualization, linux-kernel

vduse_domain_set_map() rejects the target domain's own file by comparing
file pointers. Sashiko pointed out that once VDUSE domain mappings can
be imported through vhost-vdpa, this check would allow one domain to
take a reference to another domain's file. Two domains could then keep
each other's files alive.

All VDUSE domain files use the same file operations. Compare the file
operations at import time to reject any VDUSE domain file before taking
a reference.

Link: https://lore.kernel.org/r/sashiko-outbox-234880@kernel.org
Signed-off-by: chenglong ma <longpareto@gmail.com>
---
Changes since v3:
- Split the import check into its own patch as Lorenzo requested.
  Apply it before removing VM_IO in patch 2/2.
v3: https://lore.kernel.org/r/20261130095135.862-1-longpareto@gmail.com

QEMU testing of v3 on v7.4-rc2 rejected imports of both the target
domain's file and another domain's file. An ordinary memfd mapping
imported and shared data successfully.

Codex helped split v3 and draft the commit messages for this series.

 drivers/vdpa/vdpa_user/iova_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 28a977248a0d..9955d66d9e83 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.c
+++ b/drivers/vdpa/vdpa_user/iova_domain.c
@@ -76,7 +76,7 @@ int vduse_domain_set_map(struct vduse_iova_domain *domain,
 	for (map = vhost_iotlb_itree_first(iotlb, start, last); map;
 	     map = vhost_iotlb_itree_next(map, start, last)) {
 		map_file = (struct vdpa_map_file *)map->opaque;
-		if (!map_file || map_file->file == domain->file) {
+		if (!map_file || map_file->file->f_op == domain->file->f_op) {
 			ret = -EINVAL;
 			goto err;
 		}

base-commit: 44293796526f4343639f87b2acc53811c78b5d54
-- 
2.45.2.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 2/2] vduse: don't set VM_IO on the domain file mapping
  2026-12-02  1:14 [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files chenglong ma
@ 2026-12-02  1:15 ` chenglong ma
  2026-12-02  1:20 ` [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files sashiko-bot
  2026-12-02 20:41 ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 4+ messages in thread
From: chenglong ma @ 2026-12-02  1:15 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Jason Wang, Eugenio Pérez, Xuan Zhuo, Lorenzo Stoakes (ARM),
	Xie Yongji, virtualization, linux-kernel

Commit bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page
fault path") set VM_IO on the domain file mapping so that
vhost_vdpa_va_map() would skip it.

Commit 99fd6bf43d5d ("mm/vma: enforce that mm-managed mappings may not
set VMA_IO_BIT") disallows VM_IO on mappings managed by the MM. On
v7.4-rc2, mmap() on the VDUSE domain file triggers WARN_ON_ONCE() and
returns -EINVAL, so VDUSE userspace cannot access the mapping.

Drop VM_IO to restore mmap(). This relies on "vduse: reject imports
backed by VDUSE domain files" to keep VDUSE domain files out of imported
mappings. The coherent page fault handler checks that each entry is
backed by the faulting domain's own file.

Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
Cc: <stable@vger.kernel.org> # requires "vduse: reject imports backed by VDUSE domain files"
Reported-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Closes: https://lore.kernel.org/r/awWOpS3HR_2FTN3I@gremlin
Suggested-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: chenglong ma <longpareto@gmail.com>
---
Changes since v3:
- Keep the VM_IO change on its own and restore Lorenzo's Reviewed-by.
  Together, patches 1/2 and 2/2 produce the same code as v3.
v3: https://lore.kernel.org/r/20261130095135.862-1-longpareto@gmail.com
v2: https://lore.kernel.org/r/20261126062915.209-1-longpareto@gmail.com

Please consider this mmap() regression fix for the 7.4 cycle.

Stable backported bb2e6f166547 in v7.3.5 (4c8fdb725614) and
v6.18.64 (1b46b4182d3d). Please apply patch 1/2 first when
backporting this fix.

With the combined changes, QEMU testing of v3 on v7.4-rc2 confirmed
that mmap() succeeded and a coherent vring page could be faulted in.

 drivers/vdpa/vdpa_user/iova_domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 9955d66d9e83..8acd0672fd30 100644
--- a/drivers/vdpa/vdpa_user/iova_domain.c
+++ b/drivers/vdpa/vdpa_user/iova_domain.c
@@ -588,7 +588,7 @@ static int vduse_domain_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct vduse_iova_domain *domain = file->private_data;
 
-	vm_flags_set(vma, VM_IO | VM_DONTDUMP | VM_DONTEXPAND);
+	vm_flags_set(vma, VM_DONTDUMP | VM_DONTEXPAND);
 	vma->vm_private_data = domain;
 	vma->vm_ops = &vduse_domain_mmap_ops;
 
-- 
2.45.2.windows.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files
  2026-12-02  1:14 [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files chenglong ma
  2026-12-02  1:15 ` [PATCH v4 2/2] vduse: don't set VM_IO on the domain file mapping chenglong ma
@ 2026-12-02  1:20 ` sashiko-bot
  2026-12-02 20:41 ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-02  1:20 UTC (permalink / raw)
  To: chenglong ma; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez

Sashiko has reviewed this 2-patch series and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/8c051ac47f91aa3c6583ab306b9b48f39c4a75d2.1796141756.git.longpareto@gmail.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files
  2026-12-02  1:14 [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files chenglong ma
  2026-12-02  1:15 ` [PATCH v4 2/2] vduse: don't set VM_IO on the domain file mapping chenglong ma
  2026-12-02  1:20 ` [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files sashiko-bot
@ 2026-12-02 20:41 ` Lorenzo Stoakes (ARM)
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-12-02 20:41 UTC (permalink / raw)
  To: chenglong ma
  Cc: Michael S. Tsirkin, Jason Wang, Eugenio Pérez, Xuan Zhuo,
	Xie Yongji, virtualization, linux-kernel

On Wed, Dec 02, 2026 at 09:14:16AM +0800, chenglong ma wrote:
> vduse_domain_set_map() rejects the target domain's own file by comparing
> file pointers. Sashiko pointed out that once VDUSE domain mappings can
> be imported through vhost-vdpa, this check would allow one domain to
> take a reference to another domain's file. Two domains could then keep
> each other's files alive.
>
> All VDUSE domain files use the same file operations. Compare the file
> operations at import time to reject any VDUSE domain file before taking
> a reference.
>
> Link: https://lore.kernel.org/r/sashiko-outbox-234880@kernel.org
> Signed-off-by: chenglong ma <longpareto@gmail.com>

Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

But is this not also something to Fix:/Cc: Stable? Or not after all?

> ---
> Changes since v3:
> - Split the import check into its own patch as Lorenzo requested.
>   Apply it before removing VM_IO in patch 2/2.
> v3: https://lore.kernel.org/r/20261130095135.862-1-longpareto@gmail.com
>
> QEMU testing of v3 on v7.4-rc2 rejected imports of both the target
> domain's file and another domain's file. An ordinary memfd mapping
> imported and shared data successfully.
>
> Codex helped split v3 and draft the commit messages for this series.
>
>  drivers/vdpa/vdpa_user/iova_domain.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
> index 28a977248a0d..9955d66d9e83 100644
> --- a/drivers/vdpa/vdpa_user/iova_domain.c
> +++ b/drivers/vdpa/vdpa_user/iova_domain.c
> @@ -76,7 +76,7 @@ int vduse_domain_set_map(struct vduse_iova_domain *domain,
>  	for (map = vhost_iotlb_itree_first(iotlb, start, last); map;
>  	     map = vhost_iotlb_itree_next(map, start, last)) {
>  		map_file = (struct vdpa_map_file *)map->opaque;
> -		if (!map_file || map_file->file == domain->file) {
> +		if (!map_file || map_file->file->f_op == domain->file->f_op) {
>  			ret = -EINVAL;
>  			goto err;
>  		}
>
> base-commit: 44293796526f4343639f87b2acc53811c78b5d54
> --
> 2.45.2.windows.1
>

--
Cheers, Lorenzo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  1:14 [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files chenglong ma
2026-12-02  1:15 ` [PATCH v4 2/2] vduse: don't set VM_IO on the domain file mapping chenglong ma
2026-12-02  1:20 ` [PATCH v4 1/2] vduse: reject imports backed by VDUSE domain files sashiko-bot
2026-12-02 20:41 ` Lorenzo Stoakes (ARM)

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.