vzlist: fix segfault on ploop CT with no DISKINODES set
If a ploop-based CT have no DISKINODES set in its config file
(which is perfectly legal), vzlist -o diskspace (or vzlist -j)
segfaults:
# vzlist 1016 -o diskspace
Segmentation fault (core dumped)
# vzlist -j 1016
Segmentation fault (core dumped)
gdb copy-paste:
Program received signal SIGSEGV, Segmentation fault.
get_ve_ploop_info (ve=0x64b060) at vzlist.c:1471
1471 ve->quota->diskspace[1] = ve->quota->diskspace[2] =
(gdb) p ve->quota
$1 = (struct Cquota *) 0x0
This happens because the memory for Cquota structure is allocated in
merge_conf() only if *both* DISKSPACE and DISKQUOTA are set. That made
sense before, because vzquota needed both parameters. Now with ploop
DISKINODES is not required (and ignored if set).
Solution implemented by this patch is to change that "both are set"
to "either one is set" logic in merge_conf().
In addition, check that ve->quota is not-null and allocate it in
get_ve_ploop_info(). This should help preventing SIGSEGV in case say
someone started a container and then removed DISKSPACE/DISKINODES from
its config file.
https://bugzilla.openvz.org/2488
Reported-by: Antanas <antanas@antanas.eu>
Reported-by: Maxim Leonov <st@overlogic.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed