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:
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user