From 174613bf4d76e6758775914c9e4460dcd0da0e8f Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Wed, 5 Dec 2018 11:16:27 +0100 Subject: [PATCH] vhost: reject clients with non-2MB-aligned memory size SPDK doesn't provide sufficient runtime checks to properly handle clients with memory sizes that aren't 2MB multiples and could potentially segfault during I/O processing. That's why we'll reject such clients now. Change-Id: I34e85be5b5c6df863371d0ad688f228ed44107ff Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/433640 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/vhost/vhost.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 943c2b6b37..7653546429 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1084,6 +1084,14 @@ start_device(int vid) goto out; } + for (i = 0; i < vsession->mem->nregions; i++) { + if (vsession->mem->regions[i].size & MASK_2MB) { + SPDK_ERRLOG("vhost device %d: Guest memory size is not a 2MB multiple\n", vid); + free(vsession->mem); + goto out; + } + } + /* * Not sure right now but this look like some kind of QEMU bug and guest IO * might be frozed without kicking all queues after live-migration. This look like