From 027d979fbcda6f23844b4bea995e6c6755a5f2cc Mon Sep 17 00:00:00 2001 From: Kevin Lange Date: Fri, 29 May 2015 16:12:04 -0700 Subject: [PATCH] Fix incorrectly 0'd userspace entry pointer; bad pointer validate in stat_node --- kernel/misc/elf.c | 3 +++ kernel/sys/syscall.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/misc/elf.c b/kernel/misc/elf.c index 8641d695..f9fdbf22 100644 --- a/kernel/misc/elf.c +++ b/kernel/misc/elf.c @@ -43,12 +43,15 @@ int exec_elf(char * path, fs_node_t * file, int argc, char ** argv, char ** env) release_directory_for_exec(current_directory); invalidate_page_tables(); + current_process->image.entry = 0xFFFFFFFF; + /* Load the loadable segments from the binary */ for (uintptr_t x = 0; x < (uint32_t)header->e_shentsize * header->e_shnum; x += header->e_shentsize) { /* read a section header */ Elf32_Shdr * shdr = (Elf32_Shdr *)((uintptr_t)header + (header->e_shoff + x)); if (shdr->sh_addr) { /* If this is a loadable section, load it up. */ + if (shdr->sh_addr == 0) continue; /* skip sections that try to load to 0 */ if (shdr->sh_addr < current_process->image.entry) { /* If this is the lowest entry point, store it for memory reasons */ current_process->image.entry = shdr->sh_addr; diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index 83930954..1d77d2a4 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -256,7 +256,6 @@ static int sys_seek(int fd, int offset, int whence) { static int stat_node(fs_node_t * fn, uintptr_t st) { struct stat * f = (struct stat *)st; - PTR_VALIDATE(fn); PTR_VALIDATE(f); if (!fn) {