prepare process: add magic header in program_load_desc

Check we mapped the correct region with a magic header in the struct

Original commit: d246b93a3bced92d0ac2a4a337118091b010658a

Fujitsu: POSTK_DEBUG_TEMP_FIX_76
Change-Id: If848be64af5d76844ba65b48493021637c8114f4
This commit is contained in:
Dominique Martinet
2019-01-28 17:09:24 +09:00
parent 0cc3120a01
commit 960a6f5f90
4 changed files with 14 additions and 0 deletions

View File

@ -111,7 +111,10 @@ typedef unsigned long __cpu_set_unit;
#define MPOL_NO_BSS 0x04
#define MPOL_SHM_PREMAP 0x08
#define PLD_MAGIC 0xcafecafe44332211UL
struct program_load_desc {
unsigned long magic;
int num_sections;
int cpu;
int pid;

View File

@ -276,6 +276,7 @@ struct program_load_desc *load_elf(FILE *fp, char **interp_pathp)
+ sizeof(struct program_image_section) * nhdrs);
memset(desc, '\0', sizeof(struct program_load_desc)
+ sizeof(struct program_image_section) * nhdrs);
desc->magic = PLD_MAGIC;
fseek(fp, hdr.e_phoff, SEEK_SET);
j = 0;
desc->num_sections = nhdrs;

View File

@ -441,6 +441,13 @@ static int process_msg_prepare_process(unsigned long rphys)
return -ENOMEM;
}
if (p->magic != PLD_MAGIC) {
kprintf("%s: broken mcexec program_load_desc\n", __func__);
ihk_mc_unmap_virtual(p, npages);
ihk_mc_unmap_memory(NULL, phys, sz);
return -EFAULT;
}
n = p->num_sections;
if (n > 16 || 0 >= n) {
kprintf("%s: ERROR: ELF sections other than 1 to 16 ??\n",

View File

@ -174,7 +174,10 @@ typedef unsigned long __cpu_set_unit;
#define MPOL_NO_BSS 0x04
#define MPOL_SHM_PREMAP 0x08
#define PLD_MAGIC 0xcafecafe44332211UL
struct program_load_desc {
unsigned long magic;
int num_sections;
int cpu;
int pid;