From 248c0d2fd007eeeb108ff1a88924e3ef8ff84ba4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 5 Apr 2021 00:20:13 +0200 Subject: Made kernel elf-bootable --- kernel/features/load.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'kernel/features') diff --git a/kernel/features/load.c b/kernel/features/load.c index 3dff831..d87bb94 100644 --- a/kernel/features/load.c +++ b/kernel/features/load.c @@ -9,8 +9,6 @@ #include #include -#define PROC_STACK_SIZE 0x4000 - res elf_load(const char *path, struct proc *proc) { if (!memory_valid(path)) @@ -50,8 +48,11 @@ res elf_load(const char *path, struct proc *proc) header.version != 1 || header.machine != ELF_MACHINE_386) return -ENOEXEC; + if (!memory_valid((void *)header.entry)) + return -ENOEXEC; + // ASLR - u32 rand_off = (rand() & 0xffff) * PAGE_SIZE; + u32 rand_off = header.type == ELF_ETYPE_DYN ? (rand() & 0xffff) * PAGE_SIZE : 0; // Loop through programs for (u32 i = 0; i < header.phnum; i++) { -- cgit v1.2.3