Project

General

Profile

Bug #1672 » 2016-01-19-rtld_noexec.patch

Shawn Webb, 01/19/2016 10:40 PM

View differences:

libexec/rtld-elf/rtld.c
dbg("initializing thread locks");
lockdflt_init();
if (aux_info[AT_STACKPROT] != NULL &&
aux_info[AT_STACKPROT]->a_un.a_val != 0)
stack_prot = aux_info[AT_STACKPROT]->a_un.a_val;
/*
* Load the main program, or process its program header if it is
* already loaded.
......
if (obj_main == NULL)
rtld_die();
max_stack_flags = obj->stack_flags;
if ((max_stack_flags & PF_X) == PF_X)
if ((stack_prot & PROT_EXEC) == 0)
max_stack_flags &= ~(PF_X);
} else { /* Main program already loaded. */
const Elf_Phdr *phdr;
int phnum;
......
dbg("obj_main path %s", obj_main->path);
obj_main->mainprog = true;
if (aux_info[AT_STACKPROT] != NULL &&
aux_info[AT_STACKPROT]->a_un.a_val != 0)
stack_prot = aux_info[AT_STACKPROT]->a_un.a_val;
#ifndef COMPAT_32BIT
/*
* Get the actual dynamic linker pathname from the executable if
......
break;
}
obj->stack_flags = PF_X | PF_R | PF_W;
obj->stack_flags = PF_R | PF_W;
for (ph = phdr; ph < phlimit; ph++) {
switch (ph->p_type) {
......
obj_loads++;
linkmap_add(obj); /* for GDB & dlinfo() */
max_stack_flags |= obj->stack_flags;
if ((max_stack_flags & PF_X) == PF_X)
if ((stack_prot & PROT_EXEC) == 0)
max_stack_flags &= ~(PF_X);
dbg(" %p .. %p: %s", obj->mapbase,
obj->mapbase + obj->mapsize - 1, obj->path);
(2-2/3)