Skip to content

Commit 654f209

Browse files
Vates Git Importercorentin
authored andcommitted
Filter and check hypercalls from userspace
Xen cannot determine whether a hypercall originates from userspace or kernel space. A malicious userspace may use Xen to attack the dom0 kernel. To avoid this, instead of allowing all hypercalls verbatim, block all hypercalls by default. Allow through certain hypercalls with checks. Checking involves: 1) Any pointers need to point at valid userspace memory. For this, we also need to know the size of the buffer. 2) Buffers containing pointers need to be bounced to avoid userspace changing the memory after it has been checked. After the hypercall completes, the memory needs to be bounced back. In addition, for the kexec_load call, verify the kernel to maintain Secure Boot integrity. This patch is technical debt and should be replaced by a stable hypervisor ABI and a generic mechanism for the dom0 kernel to check hypercalls made from userspace. Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com> Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com> [ Corentin: rebase from XS-9 kernel (v6.6.98 based) to UEK8 kernel (v6.12 based): - 260017f `("lsm: use default hook return value in call_int_hook()") simplified the `call_int_hook` macro, so align our usage in `security_locked_down_nowarn()`]
1 parent 434f17a commit 654f209

11 files changed

Lines changed: 1490 additions & 5 deletions

File tree

drivers/pci/pci.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5458,6 +5458,8 @@ int pci_reset_function(struct pci_dev *dev)
54585458
pci_dev_save_and_disable(dev);
54595459

54605460
rc = __pci_reset_function_locked(dev);
5461+
if (rc >= 0 && dev->quarantined)
5462+
dev->unsafe = 0;
54615463

54625464
pci_dev_restore(dev);
54635465
pci_dev_unlock(dev);

drivers/xen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ xen-evtchn-y := evtchn.o
3838
xen-gntdev-y := gntdev.o
3939
xen-gntdev-$(CONFIG_XEN_GNTDEV_DMABUF) += gntdev-dmabuf.o
4040
xen-gntalloc-y := gntalloc.o
41-
xen-privcmd-y := privcmd.o privcmd-buf.o
41+
xen-privcmd-y := privcmd.o privcmd-buf.o filter-hypercall.o
4242
obj-$(CONFIG_XEN_FRONT_PGDIR_SHBUF) += xen-front-pgdir-shbuf.o
4343
obj-$(CONFIG_XEN_UNPOPULATED_ALLOC) += unpopulated-alloc.o
4444
obj-$(CONFIG_XEN_GRANT_DMA_OPS) += grant-dma-ops.o

0 commit comments

Comments
 (0)