* [PATCH v2] vduse: don't set VM_IO on the domain file mapping
@ 2026-11-26 6:29 chenglong ma
2026-11-26 6:42 ` sashiko-bot
2026-11-30 9:51 ` [PATCH v3] " chenglong ma
0 siblings, 2 replies; 6+ messages in thread
From: chenglong ma @ 2026-11-26 6:29 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Jason Wang, Eugenio Pérez, Xuan Zhuo, Lorenzo Stoakes,
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. 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. VDUSE is currently broken in 7.4 because of this.
Drop VM_IO. 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")
Cc: stable@vger.kernel.org
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>
---
Notes:
Hotfix for 7.4: VDUSE is unusable on 7.4 without this change, so please
consider it for the 7.4 cycle.
Changes in v2:
- Moved the hotfix remark below the ---.
- Added Cc: stable, since bb2e6f166547 is marked for stable.
- Added Lorenzo Stoakes's Reviewed-by.
- Signed-off-by name changed to "chenglong ma".
v1: https://lore.kernel.org/r/20261125152800.485-1-longpareto@gmail.com
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] vduse: don't set VM_IO on the domain file mapping
2026-11-26 6:29 [PATCH v2] vduse: don't set VM_IO on the domain file mapping chenglong ma
@ 2026-11-26 6:42 ` sashiko-bot
2026-11-30 9:51 ` [PATCH v3] " chenglong ma
1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-26 6:42 UTC (permalink / raw)
To: chenglong ma; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] vduse: cross-domain file cycle leak via
vduse_domain_set_map()
--
commit 5d6d83b780f71f3d27a9d94c43292bad6883037d
Author: chenglong ma <longpareto@gmail.com>
vduse: don't set VM_IO on the domain file mapping
This commit drops VM_IO from vduse_domain_mmap() so that mmap() of the VDUSE
domain file no longer fails the mm check on mm-managed mappings.
> diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
> index 28a977248a0d3..3c6fa18703b46 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;
>
[Severity: Medium]
Can dropping VM_IO here allow two VDUSE domains to pin each other's domain
files in a reference cycle and leak both vduse_iova_domain instances?
Without VM_IO, vhost_vdpa_va_map() no longer skips MAP_SHARED mappings of
VDUSE domain files and forwards them to vduse_domain_set_map(), which only
rejects mappings backed by the target domain's own file:
drivers/vdpa/vdpa_user/iova_domain.c:vduse_domain_set_map() {
...
map_file = (struct vdpa_map_file *)map->opaque;
if (!map_file || map_file->file == domain->file) {
ret = -EINVAL;
goto err;
}
ret = vduse_iotlb_add_range(domain, map->start, map->last,
map->addr, map->perm,
...
}
If two domains (such as two address spaces on one device or two VDUSE
devices) import mappings of each other's domain files via vhost-vdpa, each
domain's iotlb holds a get_file() reference to the other's domain->file.
Imported iotlb entries are only freed in vduse_domain_release() when
domain->file's refcount reaches zero, while vduse_domain_destroy() only calls
fput(domain->file), so neither domain can ever be released.
Checking map_file->file->f_op == &vduse_domain_fops in
vduse_domain_set_map() would reject mappings of any VDUSE domain file.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126062915.209-1-longpareto@gmail.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] vduse: don't set VM_IO on the domain file mapping
2026-11-26 6:29 [PATCH v2] vduse: don't set VM_IO on the domain file mapping chenglong ma
2026-11-26 6:42 ` sashiko-bot
@ 2026-11-30 9:51 ` chenglong ma
2026-11-30 10:05 ` sashiko-bot
2026-12-01 13:33 ` Lorenzo Stoakes (ARM)
1 sibling, 2 replies; 6+ messages in thread
From: chenglong ma @ 2026-11-30 9:51 UTC (permalink / raw)
To: Michael S . Tsirkin
Cc: Jason Wang, Eugenio Perez, Xuan Zhuo, Lorenzo Stoakes, Xie Yongji,
virtualization, linux-kernel
Commit bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page
fault path") set VM_IO on the domain mapping to keep vhost-vdpa from
importing it. Since 99fd6bf43d5d, the MM rejects VM_IO on mm-managed
mappings. As a result, mmap() of the domain file warns and returns
-EINVAL, breaking VDUSE userspace.
Drop VM_IO so that userspace can mmap the domain file again. This also
makes shared mappings of VDUSE domain files eligible for import through
vhost-vdpa. The existing file pointer comparison rejects the target
domain's own file but allows a file belonging to another VDUSE domain.
Each imported entry holds a file reference, so accepting another
domain's file would allow the two domains to hold references to each
other.
All VDUSE domain files use vduse_domain_fops. Check the file operations
at import time and reject any such file before taking a reference.
Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
Cc: stable@vger.kernel.org
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>
Signed-off-by: chenglong ma <longpareto@gmail.com>
---
Please consider this for the 7.4 cycle. The mmap() regression prevents
VDUSE userspace from accessing the domain mapping.
Changes in v3:
- Reject imports backed by any VDUSE domain file, as pointed out by
Sashiko during review of v2.
- Drop Lorenzo's Reviewed-by because the import check changed.
- v2: https://lore.kernel.org/r/20261126062915.209-1-longpareto@gmail.com
Changes in v2:
- Move the hotfix request below the cut, add stable and Lorenzo's
Reviewed-by, and update the sign-off name.
- v1: https://lore.kernel.org/r/20261125152800.485-1-longpareto@gmail.com
Tested in QEMU on v7.4-rc2. The domain file could be mapped and a
coherent vring page faulted in. Imports of both the target domain's
file and a different domain's file were rejected, with no entry at the
requested IOVA. An ordinary memfd mapping imported and shared data.
drivers/vdpa/vdpa_user/iova_domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
index 28a977248a0d..8acd0672fd30 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;
}
@@ -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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] vduse: don't set VM_IO on the domain file mapping
2026-11-30 9:51 ` [PATCH v3] " chenglong ma
@ 2026-11-30 10:05 ` sashiko-bot
2026-12-01 13:33 ` Lorenzo Stoakes (ARM)
1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-11-30 10:05 UTC (permalink / raw)
To: chenglong ma; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> Commit bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page
> fault path") set VM_IO on the domain mapping to keep vhost-vdpa from
> importing it. Since 99fd6bf43d5d, the MM rejects VM_IO on mm-managed
> mappings. As a result, mmap() of the domain file warns and returns
> -EINVAL, breaking VDUSE userspace.
>
> Drop VM_IO so that userspace can mmap the domain file again. This also
> makes shared mappings of VDUSE domain files eligible for import through
> vhost-vdpa. The existing file pointer comparison rejects the target
> domain's own file but allows a file belonging to another VDUSE domain.
> Each imported entry holds a file reference, so accepting another
> domain's file would allow the two domains to hold references to each
> other.
>
> All VDUSE domain files use vduse_domain_fops. Check the file operations
> at import time and reject any such file before taking a reference.
>
> Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
> Cc: stable@vger.kernel.org
> 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>
> Signed-off-by: chenglong ma <longpareto@gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130095135.862-1-longpareto@gmail.com?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] vduse: don't set VM_IO on the domain file mapping
2026-11-30 9:51 ` [PATCH v3] " chenglong ma
2026-11-30 10:05 ` sashiko-bot
@ 2026-12-01 13:33 ` Lorenzo Stoakes (ARM)
2026-12-01 13:37 ` Michael S. Tsirkin
1 sibling, 1 reply; 6+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-12-01 13:33 UTC (permalink / raw)
To: chenglong ma
Cc: Michael S . Tsirkin, Jason Wang, Eugenio Perez, Xuan Zhuo,
Xie Yongji, virtualization, linux-kernel
On Mon, Nov 30, 2026 at 05:51:35PM +0800, chenglong ma wrote:
> Commit bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page
> fault path") set VM_IO on the domain mapping to keep vhost-vdpa from
> importing it. Since 99fd6bf43d5d, the MM rejects VM_IO on mm-managed
> mappings. As a result, mmap() of the domain file warns and returns
> -EINVAL, breaking VDUSE userspace.
>
> Drop VM_IO so that userspace can mmap the domain file again. This also
> makes shared mappings of VDUSE domain files eligible for import through
> vhost-vdpa. The existing file pointer comparison rejects the target
> domain's own file but allows a file belonging to another VDUSE domain.
> Each imported entry holds a file reference, so accepting another
> domain's file would allow the two domains to hold references to each
> other.
>
> All VDUSE domain files use vduse_domain_fops. Check the file operations
> at import time and reject any such file before taking a reference.
Now it seems like you're doing 2 fixes in 1? Why are you doing that? That's
not how patches work, you don't just shove everything into one patch?
Can you please just send these separately and reinstate my R-b on the VM_IO
fix?
Thanks.
>
> Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
> Cc: stable@vger.kernel.org
> 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>
> Signed-off-by: chenglong ma <longpareto@gmail.com>
> ---
> Please consider this for the 7.4 cycle. The mmap() regression prevents
> VDUSE userspace from accessing the domain mapping.
>
> Changes in v3:
> - Reject imports backed by any VDUSE domain file, as pointed out by
> Sashiko during review of v2.
> - Drop Lorenzo's Reviewed-by because the import check changed.
> - v2: https://lore.kernel.org/r/20261126062915.209-1-longpareto@gmail.com
>
> Changes in v2:
> - Move the hotfix request below the cut, add stable and Lorenzo's
> Reviewed-by, and update the sign-off name.
> - v1: https://lore.kernel.org/r/20261125152800.485-1-longpareto@gmail.com
>
> Tested in QEMU on v7.4-rc2. The domain file could be mapped and a
> coherent vring page faulted in. Imports of both the target domain's
> file and a different domain's file were rejected, with no entry at the
> requested IOVA. An ordinary memfd mapping imported and shared data.
>
> drivers/vdpa/vdpa_user/iova_domain.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
> index 28a977248a0d..8acd0672fd30 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;
> }
> @@ -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
--
Cheers, Lorenzo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3] vduse: don't set VM_IO on the domain file mapping
2026-12-01 13:33 ` Lorenzo Stoakes (ARM)
@ 2026-12-01 13:37 ` Michael S. Tsirkin
0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2026-12-01 13:37 UTC (permalink / raw)
To: Lorenzo Stoakes (ARM)
Cc: chenglong ma, Jason Wang, Eugenio Perez, Xuan Zhuo, Xie Yongji,
virtualization, linux-kernel
On Tue, Dec 01, 2026 at 01:33:27PM +0000, Lorenzo Stoakes (ARM) wrote:
> On Mon, Nov 30, 2026 at 05:51:35PM +0800, chenglong ma wrote:
> > Commit bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page
> > fault path") set VM_IO on the domain mapping to keep vhost-vdpa from
> > importing it. Since 99fd6bf43d5d, the MM rejects VM_IO on mm-managed
> > mappings. As a result, mmap() of the domain file warns and returns
> > -EINVAL, breaking VDUSE userspace.
> >
> > Drop VM_IO so that userspace can mmap the domain file again. This also
> > makes shared mappings of VDUSE domain files eligible for import through
> > vhost-vdpa. The existing file pointer comparison rejects the target
> > domain's own file but allows a file belonging to another VDUSE domain.
> > Each imported entry holds a file reference, so accepting another
> > domain's file would allow the two domains to hold references to each
> > other.
> >
> > All VDUSE domain files use vduse_domain_fops. Check the file operations
> > at import time and reject any such file before taking a reference.
>
> Now it seems like you're doing 2 fixes in 1? Why are you doing that? That's
> not how patches work, you don't just shove everything into one patch?
>
> Can you please just send these separately and reinstate my R-b on the VM_IO
> fix?
>
> Thanks.
>
> >
> > Fixes: bb2e6f166547 ("vduse: fix VA/PA confusion in the coherent page fault path")
> > Cc: stable@vger.kernel.org
> > 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>
> > Signed-off-by: chenglong ma <longpareto@gmail.com>
> > ---
> > Please consider this for the 7.4 cycle. The mmap() regression prevents
> > VDUSE userspace from accessing the domain mapping.
> >
> > Changes in v3:
> > - Reject imports backed by any VDUSE domain file, as pointed out by
> > Sashiko during review of v2.
> > - Drop Lorenzo's Reviewed-by because the import check changed.
> > - v2: https://lore.kernel.org/r/20261126062915.209-1-longpareto@gmail.com
> >
> > Changes in v2:
> > - Move the hotfix request below the cut, add stable and Lorenzo's
> > Reviewed-by, and update the sign-off name.
> > - v1: https://lore.kernel.org/r/20261125152800.485-1-longpareto@gmail.com
> >
> > Tested in QEMU on v7.4-rc2. The domain file could be mapped and a
> > coherent vring page faulted in. Imports of both the target domain's
> > file and a different domain's file were rejected, with no entry at the
> > requested IOVA. An ordinary memfd mapping imported and shared data.
> >
> > drivers/vdpa/vdpa_user/iova_domain.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/iova_domain.c
> > index 28a977248a0d..8acd0672fd30 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;
> > }
> > @@ -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
>
> --
> Cheers, Lorenzo
And as a new thread, not a reply to previous version.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 13:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 6:29 [PATCH v2] vduse: don't set VM_IO on the domain file mapping chenglong ma
2026-11-26 6:42 ` sashiko-bot
2026-11-30 9:51 ` [PATCH v3] " chenglong ma
2026-11-30 10:05 ` sashiko-bot
2026-12-01 13:33 ` Lorenzo Stoakes (ARM)
2026-12-01 13:37 ` Michael S. Tsirkin
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.