From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796032304; b=vkoy586vlZ85O72eDlOFyQOgXKMARcH5PjzBQ75ebi68fKqF+uVjKRRV5nA8LGD9osWl m+VBWOfSy0LYH/IvVYOpqWTmD/dgFP68Ov8IHFpArasisR2/Qf5lZiAtvo9nJL8Xjg4w+ 3LNX4LJw6uetxXjPEBFhHSkn1tUxnF2lATIQSb02yUIMDn1nxF7HTlh4yMiTmaxmQ9KLG unEWFLzrOimbvo117607dxlF+GwkuwF6ebMljpasPyf+JVsyNtgq1LY191IShDsbWUvqM S28dGO+4e/q3Fn9bqFNVjBzIR9PNkh2nzLB0rVoTRvkgZ1IVbdWtsxr87z5t/Wf/O1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796032304; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=4+YaiVR3ogqcQDSZzRnOLG534ztUe0BXH07LjIfA5zI=; b=s9YJIhem7X11EhIfZSE/yA5VBmV5byaemP8zKpM0a/2muhYZp3zOFMZZbKA5QLKYBu9X hVl+HHRJGdd049IMVajTPK4vozZOO7csXsPpQs6RTCmLcEed9Xf8Hl+JeJYZ2Ko+7POZZ vizqmOV9GGhdIutWgTFGYnPLCNu7pq/ZqZF27WVW3tIUAkNWyj9xbh9KsLN0gBGYKEpEE DA+qAfFzoOx2Mpr9fPcllipYtUswEmhAbFrKMW7+vX9tzbRifC++Mtb/GywronPXB5Wli Knam0ba8FWtvwqLHGprfcn485oGQIOf2dUwVzGlLoCYtmP9twsem3deK++kwHt1JO7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ymgpkD+N; arc=none smtp.remote-ip=209.85.216.42 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5892360A261F for ; Mon, 30 Nov 2026 09:51:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5892360A261F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ymgpkD+N Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-3b58cdb9088so193732a91.0 for ; Mon, 30 Nov 2026 01:51:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796032304; x=1796637104; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4+YaiVR3ogqcQDSZzRnOLG534ztUe0BXH07LjIfA5zI=; b=ymgpkD+NubF5iVj0q0A5+4HLrfaJOOpdeo+/NmYa4N7WhrXZey94RYUgHgAIfylYxz 45cPRF+rBDM493Fg+hr3ef5AS0jpkyJ5KhJn8wmlKxJ6blal+thCDDdJTf5yVpoeLSe0 zfjsRy7+CP+ihM8j2LcQH1Pd3o/Bpq27HwGPAw9DD2IWLlHtNnJ9rYvRtT8n7N5eZBoU 0WnlKYwgoqwYO85EQhm63up8rsYIQ3OpUvDCvljFvGH53G193+/7kUT6paOg7RAVmE2W WntK+TUBs69OI/03mslkGNsxHT9z/XC3n5ZuiOJku6RUYK3FIfnfUOaXpF/TPwnoyEgf rvow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796032304; x=1796637104; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=4+YaiVR3ogqcQDSZzRnOLG534ztUe0BXH07LjIfA5zI=; b=o5EH5jjhtSvASsc6lVqSj2dCQjrBbWa5YUVQUOJBGXpn3CVdFLAV6Fj1SxZjNki7ZV 1L2DdDqbmq2XlUHPurgJv42xbfYDxO31r/hHQ4BjpLBLZGB62ySAmb/HwlVJ4A9Qg+5C +rHZodQzTiI81/yLpvi085YVCVl1CsMJtiD6AOnhH3W3QHm3i59mZKWv0cjOoYRukRBk 5c1yyq+xSylQfcM+f95tVQSXnd+E1NuknHtfHEbyku2MjimwcN+OY7W49OXMufNFN7f/ ci6ash7F0Ml72TwrAo0vFKb+3s7e74k9vIpszyOgMngB/z5s8X9+jzJHZdkokYNGc2+m y9hg== X-Forwarded-Encrypted: i=1; AL+hErGKAbRLta3lkx3g0y8iDqDrOfu3jTiOL6bK3uUdO1i9ipVpv/6G9UcG5iAv8MrADhajIkDOEEaOH1tcFH2J2w==@lists.linux.dev X-Gm-Message-State: APuU4Z/svewCngGa9UY/QlG5aanARiYpLXJBfN9vhvlkTafvXJHI0ri/ Bslevc9TSo311IUpFmKLz79ydQVZ00ij3VV4Yv8mhB5WQZaJcUkbJqlA X-Gm-Gg: AZFdTZdriE15qE/n/v2jxzp/0c1u9a3eCF/Pdg0eRfdT3rMl/Vqnyr9eQyaOR6c/d3b 2Wo3QqZKzhTbU2PewGOlZUzQWSApWtPJn+6z6YeA+wVnDsVlOIBLrxLTbL3HrSum/7oW7kLD5az d9swUVZm/gk1CmwQD5BbfkH3Q1zslxll+zbUsZlOzF6sDCNiRL6GjnY1Hd3mbFKadUF/1u+BTiM US0t8L0Ui0dGVt4IoDINkEaD7L8YqhsXduI7icAWFFFiVkmeuOPqlLLdMnqaV2zcoeUoEW+vMZw GHpb0p/Ti0n9HUhbEf+dY4+cpsbJrU5Dd08JtZ+XXB/ZPciqyIwfyT4BocHo+xL39V2/NmkiKIy dimKBgjpvSN+Lq7yxL605FU16lh8t2w2Q8f46WBBHhFdci+QudS4rsj2d2+cIbZiREcwe9dBwQl IAseJuZl4gIHACBSR3yND9krP9s3xg5t4Wd6JCzrpWaRR0DjzT/+jNhNG+OQZtvPzUb1hEeTsY7 0BW6MSddyKrg3a4xC4Rh1Z0/C9f2Y6L1WJJPCeTH+1iWeWORhg0LnM3Vh/zmJMrdFal5IyvzTIT x7haOJVfBzYZYHPMmy9GuwMfjuDH/1RkiWy1QaD3f09vSN+VkMcb9zZtikFsISlrkU/7Jn6L9ET w X-Received: by 2002:a17:90b:388d:b0:3ac:fe93:a731 with SMTP id 98e67ed59e1d1-3b41cb235d6mr31650630a91.56.1796032303588; Mon, 30 Nov 2026 01:51:43 -0800 (PST) Received: from O1PCCC03033100.cn.corp.seagroup.com ([143.92.127.241]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b50234fb25sm11619112a91.2.2026.11.30.01.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 01:51:43 -0800 (PST) From: chenglong ma To: "Michael S . Tsirkin" Cc: Jason Wang , Eugenio Perez , Xuan Zhuo , Lorenzo Stoakes , Xie Yongji , 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 Message-ID: <20261130095135.862-1-longpareto@gmail.com> X-Mailer: git-send-email 2.45.2.windows.1 In-Reply-To: <20261126062915.209-1-longpareto@gmail.com> References: <20261126062915.209-1-longpareto@gmail.com> X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) Closes: https://lore.kernel.org/r/awWOpS3HR_2FTN3I@gremlin Suggested-by: Lorenzo Stoakes (ARM) Signed-off-by: chenglong ma --- 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