x86/boot: Don't leak the module_map allocation in __start_xen()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 Apr 2019 15:58:44 +0000 (15:58 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 13 May 2019 09:35:37 +0000 (10:35 +0100)
commit9b757bdc1794d012f5d784de54d5884e425622e0
tree897338e825c019e111993e66198512f1e716fc04
parent1e31c150f6b0efac59df1824e9881b3eb00b01b5
x86/boot: Don't leak the module_map allocation in __start_xen()

Ever since its introducion in c/s 436fb462 "x86/microcode: enable boot
time (pre-Dom0) loading", the allocation has gone un-freed, and has its final
use as part of constructing dom0.

Xen already consideres it an error to have more than a single unaccounted-for
module (again, logic from the same change), and will only pass the first one
to dom0 as the initrd.

Instead of having an 8 byte pointer to a bitmap which won't exceed 4 bits wide
in any production scenario (dom0 kernel, initrd, XSM blob and microcode blob),
allocate module_map[] on the stack and add a sanity bound for mbi->mods_count.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/setup.c