From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.28.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796116655; b=RwVAuc4+qqdPxm614MElQdSrRWdtAw2L/O3OCb6tByC006GCcOap+KUsfpUPTLdhBYmI nBJ+sTDU+Of+LEMy4pkXefsf/szVdsZTE1U8uY7EKCgookGq+l46mKEV7CE60x4zyfjc0 bileb0EmYF/w2mi4X164pgCN2u0cm96ATvitiCq9z55JpOs5pdBfR+OxK8ROkFIc8Ly+l fyKxuYiRl+4JWNx1Lhh4o6S/LUqy/Nrti3OnNGxUgYNrt+8exEgOspxyK9ruOEDAcw+MF DVaJRVD21BTIv+UQ937g+7gEXP3lUcg10Lg7/tQ6VHleMcVFNANMMAp4sn0Vwe1Gpeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796116655; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=VOHg4f1HdWpjl4kqDIEpPLPk5MFZEdqlz0P6SvWbDhs=; b=0bTgA+uQMk8Uxnr67DIX3RA3Wr4BqFZ40vZyPCLK7lurEbSBiuHHd+Tl2NXSSWm1VqQ8 D5x5W0v37ejKry5LMJ0aG3imZhlRTpETU/E8ib4ripOkqIiEOzcidoO+0YwwEuAjleBGr FHfQGZNZIWXua3JpTjGMqsnRQsq6iP564zQoPlctT36xCMc1+bnkCYGpH3IfqSFgNm9As u66q1FegUtQYbk2kE4gaQWuJg7ZkewA/2ZalqE41ARuV2J3deFVnHYiXInDT2pFZrJla9 l/eFAcDN8ZwHyURd1yDo7dL3V4GVdu7Ds6bG/F/bfYkYPh03M+42NXDQmQ/cBIp5sjg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=xiaopeng.com; spf=pass smtp.mailfrom=xiaopeng.com; dkim=pass header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=GPm+dk7H; arc=none smtp.remote-ip=115.124.28.148 Received: from out28-148.mail.aliyun.com (out28-148.mail.aliyun.com [115.124.28.148]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FFD2606A320; Tue, 1 Dec 2026 09:17:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7FFD2606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaopeng.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=xiaopeng.com header.i=@xiaopeng.com header.a=rsa-sha256 header.s=default header.b=GPm+dk7H DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=xiaopeng.com; s=default; t=1796116644; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=VOHg4f1HdWpjl4kqDIEpPLPk5MFZEdqlz0P6SvWbDhs=; b=GPm+dk7HSH5xdXR0eOlGDUVUqoPclP/IIOwJe2qErjQ+hREzIlVNLnt7oV7VeSLr87ErDcS0v1/+RGgh5yGZb5HxuW91hQWRdqsWUwu52hn8HGuWmPl9ws7XySuBh9dKPT+p3csPTq7aDZa3jG1y2v49NggfZDDhxYOg6qwlReE= X-Alimail-AntiSpam:AC=CONTINUE;BC=0.05600889|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0261335-0.00126391-0.972603;FP=10657372862706624451|0|0|0|0|-1|-1|-1;HT=maildocker-contentspam033032106048;MF=fangxy@xiaopeng.com;NM=1;PH=DS;RN=10;RT=10;SR=0;TI=SMTPD_---.kE3zIk-_1796116642; Received: from localhost.localdomain(mailfrom:fangxy@xiaopeng.com fp:SMTPD_---.kE3zIk-_1796116642 cluster:ay29) by smtp.aliyun-inc.com; Tue, 01 Dec 2026 17:17:24 +0800 From: Fang Xieyan To: "Michael S . Tsirkin" , jasowangio@gmail.com, eperezma@redhat.com Cc: fan.jiaming@hotmail.com, xiongweimin@kylinos.cn, xieyongji@bytedance.com, virtualization@lists.linux.dev, kvm@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/2] vhost-vdpa: reject mappings over unmapped VA gaps Date: Tue, 1 Dec 2026 17:17:20 +0800 Message-ID: <20261201091722.46805-1-fangxy@xiaopeng.com> X-Mailer: git-send-email 2.50.1 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vhost_vdpa_va_map() walks a request with find_vma(), which returns the first VMA whose vm_end is past the address and says nothing about vm_start. When uaddr lies in an unmapped gap that VMA is used anyway: uaddr - vma->vm_start wraps in u64 arithmetic, so the segment is filed under a file offset that belongs to no VMA. Two patches, to be applied in this order: 1/2 vhost-vdpa: reject zero-size unmap Weimin Xiong's 2026-07-16 patch, rebased onto v7.4-rc5, his authorship and Eugenio's Acked-by kept. 2/2 vhost-vdpa: use vma_lookup() in vhost_vdpa_va_map() The one-line change Jiaming Fan suggested while reviewing v2, with Cc stable. Patch 2 has to come after patch 1 because vma_lookup() makes a request that reaches a gap fail on the first iteration, and the rollback in vhost_vdpa_va_map() then runs with size 0, which is the case patch 1 closes. Measured on v7.4-rc5 with two probe vdpa parents, one with dma_map() and one with set_map() only, and the four states built from the files of this series. For a one page request whose uaddr lies in a hole below a shared file-backed VMA: pristine mapped, offset=0xfffffffffffff000 reaches the parent patch 2 -EINVAL, and the rollback removes every mapping of the address space, two of them not named by the request patch 1 + 2 -EINVAL, and those mappings survive Removing the whole table is not new with patch 2: it is already reachable today with a uaddr above every VMA, and that is the route on which the set_map-only parent was seen to be reprogrammed with an empty table (set_map, nmaps 0). Patch 1 stops both cases. Changes in v3: - vma_lookup() instead of skipping the unmapped gap, following Jiaming Fan: skipping leaves a request with a hole in the middle partly mapped, and userspace cannot tell that from one mapped in full - patch 1 added, so that the guard and the lookup change land together Weimin: your authorship and Eugenio's Acked-by are intact on patch 1 and you are cc'd on the series; if you would rather resend it yourself, say so and I will drop it from mine. Link: https://lore.kernel.org/all/20261126072414.97199-1-fangxy@xiaopeng.com/ Link: https://lore.kernel.org/all/20260716030238.124368-1-xiongwm2026@163.com/ Signed-off-by: Fang Xieyan Fang Xieyan (1): vhost-vdpa: use vma_lookup() in vhost_vdpa_va_map() xiongweimin (1): vhost-vdpa: reject zero-size unmap drivers/vhost/vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.50.1