mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chenglong ma <longpareto@gmail.com>
To: "Michael S . Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowangio@gmail.com>,
	Eugenio Perez <eperezma@redhat.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	Lorenzo Stoakes <ljs@kernel.org>,
	Xie Yongji <xieyongji@bytedance.com>,
	virtualization@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v3] vduse: don't set VM_IO on the domain file mapping
Date: Mon, 30 Nov 2026 17:51:35 +0800	[thread overview]
Message-ID: <20261130095135.862-1-longpareto@gmail.com> (raw)
In-Reply-To: <20261126062915.209-1-longpareto@gmail.com>

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

      reply	other threads:[~2026-11-30  9:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  6:29 [PATCH v2] " chenglong ma
2026-11-30  9:51 ` chenglong ma [this message]

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=20261130095135.862-1-longpareto@gmail.com \
    --to=longpareto@gmail.com \
    --cc=eperezma@redhat.com \
    --cc=jasowangio@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xieyongji@bytedance.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /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

all inboxes | Powered by JetHome®