From 099c99482f7ac032bf04caad13a9ca1da7ce58ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Marques?= Date: Tue, 1 Oct 2019 12:13:28 +0100 Subject: Only accept statically linked binaries (#176) --- pk/elf.c | 3 +++ pk/elf.h | 1 + 2 files changed, 4 insertions(+) (limited to 'pk') diff --git a/pk/elf.c b/pk/elf.c index 43810ec..3a47e7e 100644 --- a/pk/elf.c +++ b/pk/elf.c @@ -71,6 +71,9 @@ void load_elf(const char* fn, elf_info* info) info->entry = eh.e_entry + bias; int flags = MAP_FIXED | MAP_PRIVATE; for (int i = eh.e_phnum - 1; i >= 0; i--) { + if(ph[i].p_type == PT_INTERP) { + panic("not a statically linked ELF program"); + } if(ph[i].p_type == PT_LOAD && ph[i].p_memsz) { uintptr_t prepad = ph[i].p_vaddr % RISCV_PGSIZE; uintptr_t vaddr = ph[i].p_vaddr + bias; diff --git a/pk/elf.h b/pk/elf.h index 99b2aee..3d1fae1 100644 --- a/pk/elf.h +++ b/pk/elf.h @@ -26,6 +26,7 @@ #define EF_RISCV_RVC 1 #define PT_LOAD 1 +#define PT_INTERP 3 #define AT_NULL 0 #define AT_PHDR 3 -- cgit v1.1