mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
dm: cleanup 'assert' for guest software loading module
cleanup 'assert' to avoid possible vulnerabilities. Tracked-On: #3252 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
parent
0e046c7a0a
commit
ec626482d2
@ -121,8 +121,8 @@ acrn_parse_bootargs(char *arg)
|
||||
with_bootargs = 1;
|
||||
printf("SW_LOAD: get bootargs %s\n", bootargs);
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char*
|
||||
@ -222,8 +222,6 @@ acrn_create_e820_table(struct vmctx *ctx, struct e820_entry *e820)
|
||||
uint32_t removed = 0, k;
|
||||
|
||||
memcpy(e820, e820_default_entries, sizeof(e820_default_entries));
|
||||
|
||||
assert(ctx->lowmem > e820[LOWRAM_E820_ENTRY].baseaddr);
|
||||
e820[LOWRAM_E820_ENTRY].length = ctx->lowmem -
|
||||
e820[LOWRAM_E820_ENTRY].baseaddr;
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <elf.h>
|
||||
|
||||
@ -95,19 +94,19 @@ struct multiboot_info {
|
||||
int
|
||||
acrn_parse_elf(char *arg)
|
||||
{
|
||||
int err = -1;
|
||||
size_t len = strnlen(arg, STR_LEN);
|
||||
size_t elfsz;
|
||||
|
||||
if (len < STR_LEN) {
|
||||
strncpy(elf_path, arg, len + 1);
|
||||
assert(check_image(elf_path, 0, &elfsz) == 0);
|
||||
|
||||
elf_file_name = elf_path;
|
||||
|
||||
printf("SW_LOAD: get elf path %s\n", elf_path);
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
if (check_image(elf_path, 0, &elfsz) == 0) {
|
||||
elf_file_name = elf_path;
|
||||
printf("SW_LOAD: get elf path %s\n", elf_path);
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int load_elf32(struct vmctx *ctx, FILE *fp, void *buf)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "dm.h"
|
||||
#include "vmmapi.h"
|
||||
@ -72,20 +71,19 @@ ovmf_image_size(void)
|
||||
int
|
||||
acrn_parse_ovmf(char *arg)
|
||||
{
|
||||
int error;
|
||||
int error = -1;
|
||||
size_t len = strnlen(arg, STR_LEN);
|
||||
|
||||
if (len < STR_LEN) {
|
||||
strncpy(ovmf_path, arg, len + 1);
|
||||
error = check_image(ovmf_path, 2 * MB, &ovmf_size);
|
||||
assert(!error);
|
||||
|
||||
ovmf_file_name = ovmf_path;
|
||||
printf("SW_LOAD: get ovmf path %s, size 0x%lx\n",
|
||||
ovmf_path, ovmf_size);
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
if (check_image(ovmf_path, 2 * MB, &ovmf_size) == 0) {
|
||||
ovmf_file_name = ovmf_path;
|
||||
printf("SW_LOAD: get ovmf path %s, size 0x%lx\n",
|
||||
ovmf_path, ovmf_size);
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -149,7 +147,8 @@ acrn_sw_load_ovmf(struct vmctx *ctx)
|
||||
e820 = paddr_guest2host(ctx, OVMF_E820_BASE,
|
||||
e820_default_entries[LOWRAM_E820_ENTRY].baseaddr -
|
||||
OVMF_E820_BASE);
|
||||
assert(e820 != NULL);
|
||||
if (e820 == NULL)
|
||||
return -1;
|
||||
|
||||
strncpy(e820->signature, "820", sizeof(e820->signature));
|
||||
e820->nentries = acrn_create_e820_table(ctx, e820->map);
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dm.h"
|
||||
@ -125,21 +124,19 @@ vsbl_set_bdf(int bnum, int snum, int fnum)
|
||||
int
|
||||
acrn_parse_guest_part_info(char *arg)
|
||||
{
|
||||
int error;
|
||||
int error = -1;
|
||||
size_t len = strnlen(arg, STR_LEN);
|
||||
|
||||
if (len < STR_LEN) {
|
||||
strncpy(guest_part_info_path, arg, len + 1);
|
||||
error = check_image(guest_part_info_path, 0, &guest_part_info_size);
|
||||
assert(!error);
|
||||
|
||||
with_guest_part_info = true;
|
||||
|
||||
printf("SW_LOAD: get partition blob path %s\n",
|
||||
guest_part_info_path);
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
if (check_image(guest_part_info_path, 0, &guest_part_info_size) == 0) {
|
||||
with_guest_part_info = true;
|
||||
printf("SW_LOAD: get partition blob path %s\n",
|
||||
guest_part_info_path);
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -194,21 +191,18 @@ acrn_prepare_guest_part_info(struct vmctx *ctx)
|
||||
int
|
||||
acrn_parse_vsbl(char *arg)
|
||||
{
|
||||
int error;
|
||||
int error = -1;
|
||||
size_t len = strnlen(arg, STR_LEN);
|
||||
|
||||
if (len < STR_LEN) {
|
||||
strncpy(vsbl_path, arg, len + 1);
|
||||
error = check_image(vsbl_path, 8 * MB, &vsbl_size);
|
||||
assert(!error);
|
||||
|
||||
vsbl_file_name = vsbl_path;
|
||||
|
||||
printf("SW_LOAD: get vsbl path %s\n",
|
||||
vsbl_path);
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
if (check_image(vsbl_path, 8 * MB, &vsbl_size) == 0) {
|
||||
vsbl_file_name = vsbl_path;
|
||||
printf("SW_LOAD: get vsbl path %s\n", vsbl_path);
|
||||
error = 0;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user