[PATCH] vduse: don't set VM_IO on the domain file mapping

chenglong.ma posted 1 patch 2 hours ago
There is a newer version of this series
drivers/vdpa/vdpa_user/iova_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] vduse: don't set VM_IO on the domain file mapping
Posted by chenglong.ma 2 hours ago
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. Since 99fd6bf43d5d, mm refuses VM_IO
on mm-managed mappings: mmap() of the domain file fails with a
WARN_ON_ONCE() and -EINVAL, which breaks VDUSE userspace.

VM_IO is not needed. vduse_domain_set_map() already rejects vhost-vdpa
entries backed by the domain file, and the file check in
vduse_domain_get_coherent_page() keeps any other entry from being
translated as a physical address. A self-referencing mapping now
reaches vduse_domain_set_map() and is refused with -EINVAL.

Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
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>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: chenglong.ma <longpareto@gmail.com>
---

Notes:
    Tested on v7.4-rc2 (commit 7475ea8b58616b33c04afb976cf0fbaad9dd63fb).
    
    Control, without this patch: mmap() of the VDUSE domain file fails,
    with the WARN_ON_ONCE() from 99fd6bf43d5d.
    
    With this patch applied: mmap() of the domain file succeeds, and
    importing that mapping through vhost-vdpa is refused by
    vduse_domain_set_map() with -EINVAL.
    
    Dynamic tests also confirmed that vduse_domain_get_coherent_page()
    refuses to translate entries backed by any file other than the domain
    file, and that legitimate coherent vring mappings are still translated.

 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..3c6fa18703b4 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;
 

base-commit: 44293796526f4343639f87b2acc53811c78b5d54
-- 
2.45.2.windows.1
Re: [PATCH] vduse: don't set VM_IO on the domain file mapping
Posted by Lorenzo Stoakes (ARM) an hour ago
On Wed, Nov 25, 2026 at 11:28:00PM +0800, chenglong.ma wrote:
> 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. Since 99fd6bf43d5d, mm refuses VM_IO
> on mm-managed mappings: mmap() of the domain file fails with a
> WARN_ON_ONCE() and -EINVAL, which breaks VDUSE userspace.
>
> VM_IO is not needed. vduse_domain_set_map() already rejects vhost-vdpa
> entries backed by the domain file, and the file check in
> vduse_domain_get_coherent_page() keeps any other entry from being
> translated as a physical address. A self-referencing mapping now
> reaches vduse_domain_set_map() and is refused with -EINVAL.

You should probably point out that the driver is _literally broken right now_ in
7.4. This is kinda urgent for those who use it :)

>
> Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
> 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>
> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This tag is invalid. See the process on this [0]

[0]: https://docs.kernel.org/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by

> Signed-off-by: chenglong.ma <longpareto@gmail.com>

Patch looks right though.

This is pretty urgent, so should be sent as a hotfix.

With the tag/commit msg bits addressed:

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

> ---
>
> Notes:
>     Tested on v7.4-rc2 (commit 7475ea8b58616b33c04afb976cf0fbaad9dd63fb).
>
>     Control, without this patch: mmap() of the VDUSE domain file fails,
>     with the WARN_ON_ONCE() from 99fd6bf43d5d.
>
>     With this patch applied: mmap() of the domain file succeeds, and
>     importing that mapping through vhost-vdpa is refused by
>     vduse_domain_set_map() with -EINVAL.
>
>     Dynamic tests also confirmed that vduse_domain_get_coherent_page()
>     refuses to translate entries backed by any file other than the domain
>     file, and that legitimate coherent vring mappings are still translated.
>
>  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..3c6fa18703b4 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;
>
>
> base-commit: 44293796526f4343639f87b2acc53811c78b5d54
> --
> 2.45.2.windows.1
>

--
Cheers, Lorenzo