[PATCH] virsh: Fix integer overflow in allocpages

Ján Tomko jtomko at redhat.com
Thu Mar 31 10:59:05 UTC 2022

On a Wednesday in 2022, Michal Privoznik wrote:
>I've came across an aarch64 system which supports hugepages up to
>16GiB of size. However, I was unable to allocate them using
>virsh allocpages. This is because cmdAllocpages() uses
>vshCommandOptScaledInt(), which scales passed value into bytes,
>but since the virNodeAllocPages() expects size in KiB the
>variable holding bytes is then divided by 1024. However, the
>limit for the biggest value passed to vshCommandOptScaledInt() is
>UINT_MAX which is now obviously wrong, as it needs to be UINT_MAX
>* 1024.
>The same bug is in completer. But here, let's use ULLONG_MAX so
>that we don't have to care about it anymore.
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> tools/virsh-completer-host.c | 2 +-
> tools/virsh-host.c           | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Ján Tomko <jtomko at redhat.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220331/a91c47c2/attachment.sig>

More information about the libvir-list mailing list