[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 2/5] libvhost-user: Add vu_add_mem_reg input validation
From: |
Raphael Norwitz |
Subject: |
[RFC 2/5] libvhost-user: Add vu_add_mem_reg input validation |
Date: |
Wed, 15 Dec 2021 22:29:51 +0000 |
Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
---
subprojects/libvhost-user/libvhost-user.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/subprojects/libvhost-user/libvhost-user.c
b/subprojects/libvhost-user/libvhost-user.c
index 573212a83b..80ef335254 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -690,6 +690,12 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
VuDevRegion *dev_region = &dev->regions[dev->nregions];
void *mmap_addr;
+ if (vmsg->fd_num != 1 ||
+ vmsg->size != sizeof(vmsg->payload.memreg)) {
+ vu_panic(dev, "VHOST_USER_REM_MEM_REG received multiple regions");
+ return true;
+ }
+
/*
* If we are in postcopy mode and we receive a u64 payload with a 0 value
* we know all the postcopy client bases have been received, and we
--
2.20.1