As detailed in commit
0fe607b2a144 ("x86/boot: Fix PVH boot during boot_info
transition period"), the use of __va(mbi->mods_addr) constitutes a
use-after-free on the PVH boot path.
This pattern has been in use since before PVH support was added. This has
most likely gone unnoticed because no-one's tried using a detached Flask
policy in a PVH VM before.
Plumb the boot_info pointer down, replacing module_map and mbi. Importantly,
bi->mods[].mod is a safe way to access the module list during PVH boot.
As this is the final non-bi use of mbi in __start_xen(), make the pointer
unusable once bi has been established, to prevent new uses creeping back in.
This is a stopgap until mbi can be fully removed.
Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
master commit:
6cf0aaeb8df951fb34679f0408461a5c67cb02c6
master date: 2024-10-23 18:14:24 +0100
mmio_ro_ranges = rangeset_new(NULL, "r/o mmio ranges",
RANGESETF_prettyprint_hex);
- xsm_multiboot_init(module_map, mbi);
+ xsm_multiboot_init(module_map, mbi, mod);
/*
* IOMMU-related ACPI table parsing may require some of the system domains
#ifdef CONFIG_MULTIBOOT
int xsm_multiboot_init(
- unsigned long *module_map, const multiboot_info_t *mbi);
+ unsigned long *module_map, const multiboot_info_t *mbi,
+ const module_t mods[]);
int xsm_multiboot_policy_init(
unsigned long *module_map, const multiboot_info_t *mbi,
+ const module_t mods[],
void **policy_buffer, size_t *policy_size);
#endif
#ifdef CONFIG_MULTIBOOT
static inline int xsm_multiboot_init (
- unsigned long *module_map, const multiboot_info_t *mbi)
+ unsigned long *module_map, const multiboot_info_t *mbi,
+ const module_t mods[])
{
return 0;
}
#ifdef CONFIG_MULTIBOOT
int __init xsm_multiboot_init(
- unsigned long *module_map, const multiboot_info_t *mbi)
+ unsigned long *module_map, const multiboot_info_t *mbi,
+ const module_t mods[])
{
int ret = 0;
void *policy_buffer = NULL;
if ( XSM_MAGIC )
{
- ret = xsm_multiboot_policy_init(module_map, mbi, &policy_buffer,
- &policy_size);
+ ret = xsm_multiboot_policy_init(module_map, mbi, mods,
+ &policy_buffer, &policy_size);
if ( ret )
{
bootstrap_map(NULL);
#ifdef CONFIG_MULTIBOOT
int __init xsm_multiboot_policy_init(
unsigned long *module_map, const multiboot_info_t *mbi,
+ const module_t mod[],
void **policy_buffer, size_t *policy_size)
{
int i;
- module_t *mod = (module_t *)__va(mbi->mods_addr);
int rc = 0;
u32 *_policy_start;
unsigned long _policy_len;