From d557ba84d65f48a2fcf6f2ef71ae695ec7ea288f Mon Sep 17 00:00:00 2001 From: NAKAMURA Gou Date: Mon, 21 Oct 2013 18:55:02 +0900 Subject: [PATCH] exclude interpreter's segment from data region When an interpreter is located on the lower address (e.g. 0x0), the text region is included in data region. A fix to avoid this. --- executer/include/uprotocol.h | 3 ++- executer/user/mcexec.c | 2 ++ kernel/host.c | 5 ++++- kernel/include/syscall.h | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/executer/include/uprotocol.h b/executer/include/uprotocol.h index 722efbee..6ef3a2b5 100644 --- a/executer/include/uprotocol.h +++ b/executer/include/uprotocol.h @@ -25,7 +25,8 @@ struct program_image_section { unsigned long remote_pa; unsigned long filesz, offset; int prot; - int padding; + unsigned char interp; + unsigned char padding[3]; void *fp; }; diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 642a1e7b..48535136 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -145,6 +145,7 @@ struct program_load_desc *load_elf(FILE *fp, char **interp_pathp) desc->sections[j].filesz = phdr.p_filesz; desc->sections[j].offset = phdr.p_offset; desc->sections[j].len = phdr.p_memsz; + desc->sections[j].interp = 0; desc->sections[j].fp = fp; desc->sections[j].prot = PROT_NONE; @@ -255,6 +256,7 @@ struct program_load_desc *load_interp(struct program_load_desc *desc0, FILE *fp) desc->sections[j].filesz = phdr.p_filesz; desc->sections[j].offset = phdr.p_offset; desc->sections[j].len = phdr.p_memsz; + desc->sections[j].interp = 1; desc->sections[j].fp = fp; desc->sections[j].prot = PROT_NONE; diff --git a/kernel/host.c b/kernel/host.c index beec8bd9..b57120e1 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -133,7 +133,10 @@ static int process_msg_prepare_process(unsigned long rphys) p->sections[i].remote_pa = up; /* TODO: Maybe we need flag */ - if (i == 0) { + if (pn->sections[i].interp) { + /* nothing to do */ + } + else if (i == 0) { proc->vm->region.text_start = s; proc->vm->region.text_end = e; } else if (i == 1) { diff --git a/kernel/include/syscall.h b/kernel/include/syscall.h index 744c6d04..1907287d 100644 --- a/kernel/include/syscall.h +++ b/kernel/include/syscall.h @@ -84,7 +84,8 @@ struct program_image_section { unsigned long remote_pa; unsigned long filesz, offset; int prot; - int padding; + unsigned char interp; + unsigned char padding[3]; void *fp; };