linux/drivers/xen
Juergen Gross 2b985d3a02 xen/privcmd: fix double free via VMA splitting
commit 24daca4fc0 upstream.

privcmd_vm_ops defines .close (privcmd_close), but neither .may_split
nor .open. When userspace does a partial munmap() on a privcmd mapping,
the kernel splits the VMA via __split_vma(). Since may_split is NULL,
the split is allowed. vm_area_dup() copies vm_private_data (a pages
array allocated in alloc_empty_pages()) into the new VMA without any
fixup, because there is no .open callback.

Both VMAs now point to the same pages array. When the unmapped portion
is closed, privcmd_close() calls:
    - xen_unmap_domain_gfn_range()
    - xen_free_unpopulated_pages()
    - kvfree(pages)

The surviving VMA still holds the dangling pointer. When it is later
destroyed, the same sequence runs again, which leads to a double free.

Fix this issue by adding a .may_split callback denying the VMA split.

This is XSA-487 / CVE-2026-31787

Fixes: d71f513985 ("xen: privcmd: support autotranslated physmap guests.")
Reported-by: Atharva Vartak <atharva.a.vartak@gmail.com>
Suggested-by: Atharva Vartak <atharva.a.vartak@gmail.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-30 11:24:38 +02:00
..
events xen/events: Update virq_to_irq on migration 2025-10-19 16:21:55 +02:00
xen-pciback xen-pciback: Consider INTx disabled when MSI/MSI-X is enabled 2023-11-20 11:08:20 +01:00
xenbus xenbus: Use .freeze/.thaw to handle xenbus devices 2026-03-04 07:19:59 -05:00
xenfs xenfs/xensyms: respect hypervisor's "next" indication 2025-05-02 07:43:59 +02:00
acpi.c xen: rename dom0_op to platform_op 2015-12-21 14:40:55 +00:00
arm-device.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 201 2019-05-30 11:29:52 -07:00
balloon.c xen/balloon: add late_initcall_sync() for initial ballooning done 2021-11-18 19:16:04 +01:00
biomerge.c block: pass page to xen_biovec_phys_mergeable 2019-04-01 12:11:13 -06:00
cpu_hotplug.c xen/cpuhotplug: Fix initial CPU offlining for PV(H) guests 2020-05-21 13:01:45 -05:00
dbgp.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
efi.c xen/efi: have a common runtime setup function 2019-10-02 10:31:07 -04:00
evtchn.c xen/evtchn: use READ/WRITE_ONCE() for accessing ring indices 2021-02-23 10:07:52 -06:00
features.c x86/xen: Remove undefined behavior in setup_features() 2022-06-29 09:03:24 +02:00
gntalloc.c xen/gntalloc: don't use gnttab_query_foreign_access() 2022-03-11 12:22:36 +01:00
gntdev-common.h xen/gntdev: remove struct gntdev_copy_batch from stack 2025-08-28 16:24:08 +02:00
gntdev-dmabuf.c xen/gntdev: Fix the abuse of underlying struct page in DMA-buf import 2024-02-23 08:54:50 +01:00
gntdev-dmabuf.h xen/gntdev: Do not destroy context while dma-bufs are in use 2019-02-18 06:50:03 +01:00
gntdev.c xen/gntdev: remove struct gntdev_copy_batch from stack 2025-08-28 16:24:08 +02:00
grant-table.c xen: replace xen_remap() with memremap() 2025-07-17 18:30:48 +02:00
Kconfig xen: Change xen-acpi-processor dom0 dependency 2025-05-02 07:44:36 +02:00
Makefile xen: Remove support for PV ACPI cpu/memory hotplug 2021-04-23 09:31:50 +02:00
manage.c xen/manage: Fix suspend error path 2025-10-19 16:21:44 +02:00
mcelog.c xen/mcelog: add PPIN to record when available 2019-11-14 10:01:57 +01:00
mem-reservation.c xen/balloon: add runtime control for scrubbing ballooned out pages 2018-09-14 08:51:10 -04:00
pci.c xen/pci: reserve MCFG areas earlier 2019-09-12 15:02:55 -04:00
pcpu.c ACPI: processor: Fix evaluating _PDC method when running as Xen dom0 2023-05-11 23:00:22 +09:00
platform-pci.c xen: Add support for XenServer 6.1 platform device 2025-06-04 14:37:57 +02:00
privcmd-buf.c xen/privcmd-buf.c: convert to use vm_map_pages_zero() 2019-05-14 09:47:50 -07:00
privcmd.c xen/privcmd: fix double free via VMA splitting 2026-04-30 11:24:38 +02:00
privcmd.h xen: add new hypercall buffer mapping device 2018-06-22 08:26:42 +02:00
pvcalls-back.c xen/pvcalls-back: fix double frees with pvcalls_new_active_socket() 2023-05-30 13:55:32 +01:00
pvcalls-front.c xen/pvcalls: use alloc/free_pages_exact() 2022-03-11 12:22:36 +01:00
pvcalls-front.h xen: fix poll misannotation 2018-02-01 10:07:32 -05:00
swiotlb-xen.c xen/swiotlb: relax alignment requirements 2025-06-04 14:38:07 +02:00
sys-hypervisor.c Buffer overflow in drivers/xen/sys-hypervisor.c 2026-04-30 11:24:38 +02:00
time.c x86/paravirt: Switch time pvops functions to use static_call() 2021-03-11 16:17:52 +01:00
unpopulated-alloc.c xen/unpopulated-alloc: fix error return code in fill_list() 2021-05-10 09:42:25 +02:00
xen-acpi-pad.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
xen-acpi-processor.c xen/acpi-processor: fix _CST detection using undersized evaluation buffer 2026-04-18 10:33:10 +02:00
xen-balloon.c xen: Use DEVICE_ATTR_*() macro 2021-07-05 09:23:31 +02:00
xen-front-pgdir-shbuf.c xen-front-pgdir-shbuf: don't record wrong grant handle upon error 2021-02-23 12:35:43 -06:00
xen-scsiback.c scsi: xen: scsiback: Fix potential memory leak in scsiback_remove() 2026-02-06 16:42:01 +01:00
xlate_mmu.c xen: unexport __init-annotated xen_xlate_map_ballooned_pages() 2022-06-14 18:36:17 +02:00