diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index 2fed792e85..52817cc733 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1105,6 +1105,13 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg) vu_remove_all_mem_regs(dev); DPRINT("Nregions: %u\n", memory->nregions); + + if (memory->nregions > VHOST_MEMORY_BASELINE_NREGIONS) { + vu_panic(dev, "Invalid set_mem_table nregions: %u > %u", + memory->nregions, VHOST_MEMORY_BASELINE_NREGIONS); + return false; + } + for (i = 0; i < memory->nregions; i++) { _vu_add_mem_reg(dev, &memory->regions[i], vmsg->fds[i]); close(vmsg->fds[i]);