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 <[email protected]> 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/[email protected]?part=1
