xmalloc: guard against integer overflow
authorJan Beulich <jbeulich@suse.com>
Thu, 6 Feb 2020 08:53:12 +0000 (09:53 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 6 Feb 2020 08:53:12 +0000 (09:53 +0100)
commitcf38b4926e2b55d1d7715cff5095a7444f5ed42d
tree7ba6395fb94e9aacafa1f5a08c542e77fdbf03ba
parent4783ee894f6bfb0f4deec9f1fe8e7faceafaa1a2
xmalloc: guard against integer overflow

There are hypercall handling paths (EFI ones are what this was found
with) needing to allocate buffers of a caller specified size. This is
generally fine, as our page allocator enforces an upper bound on all
allocations. However, certain extremely large sizes could, when adding
in allocator overhead, result in an apparently tiny allocation size,
which would typically result in either a successful allocation, but a
severe buffer overrun when using that memory block, or in a crash right
in the allocator code.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/common/xmalloc_tlsf.c