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 <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/433640
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Darek Stojaczyk 2018-12-05 11:16:27 +01:00 committed by Jim Harris
parent 199080cfa2
commit 174613bf4d

View File

@ -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