am 3b84e4bc: am 3cc3f17a: Merge "linker: never mark pages simultaneously writable / executable"
* commit '3b84e4bcd020cb917067fa87e4a60a62c5c42928': linker: never mark pages simultaneously writable / executable
This commit is contained in:
commit
c68d6bcd8e
@ -429,9 +429,15 @@ static int _phdr_table_set_load_prot(const ElfW(Phdr)* phdr_table, size_t phdr_c
|
||||
ElfW(Addr) seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias;
|
||||
ElfW(Addr) seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias;
|
||||
|
||||
int prot = PFLAGS_TO_PROT(phdr->p_flags);
|
||||
if ((extra_prot_flags & PROT_WRITE) != 0) {
|
||||
// make sure we're never simultaneously writable / executable
|
||||
prot &= ~PROT_EXEC;
|
||||
}
|
||||
|
||||
int ret = mprotect(reinterpret_cast<void*>(seg_page_start),
|
||||
seg_page_end - seg_page_start,
|
||||
PFLAGS_TO_PROT(phdr->p_flags) | extra_prot_flags);
|
||||
prot | extra_prot_flags);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user