mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] vhost-vdpa: reject mappings over unmapped VA gaps
@ 2026-12-01  9:17 Fang Xieyan
  2026-12-01  9:17 ` [PATCH v3 1/2] vhost-vdpa: reject zero-size unmap Fang Xieyan
  2026-12-01  9:17 ` [PATCH v3 2/2] vhost-vdpa: use vma_lookup() in vhost_vdpa_va_map() Fang Xieyan
  0 siblings, 2 replies; 3+ messages in thread
From: Fang Xieyan @ 2026-12-01  9:17 UTC (permalink / raw)
  To: Michael S . Tsirkin, jasowangio, eperezma
  Cc: fan.jiaming, xiongweimin, xieyongji, virtualization, kvm, netdev,
	linux-kernel

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 <fangxy@xiaopeng.com>

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-01  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  9:17 [PATCH v3 0/2] vhost-vdpa: reject mappings over unmapped VA gaps Fang Xieyan
2026-12-01  9:17 ` [PATCH v3 1/2] vhost-vdpa: reject zero-size unmap Fang Xieyan
2026-12-01  9:17 ` [PATCH v3 2/2] vhost-vdpa: use vma_lookup() in vhost_vdpa_va_map() Fang Xieyan

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®