diff options
author | Luke <luke.wilde@live.co.uk> | 2020-09-09 08:40:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-27 01:02:11 +0200 |
commit | b3be275cf78e0904f6949390dbe48d8ddd090c7e (patch) | |
tree | 88dd9b684e944a056ba83daeab49bf497ce2d1e8 /Libraries/LibELF/Validation.cpp | |
parent | 9d8f1032b70713207670b571660a42d29b1814ae (diff) | |
download | serenity-b3be275cf78e0904f6949390dbe48d8ddd090c7e.zip |
LibELF: Validate PT_GNU_RELRO program header
I'm not sure if this is the correct validation. This is based on
it being "read-only after relocation".
Diffstat (limited to 'Libraries/LibELF/Validation.cpp')
-rw-r--r-- | Libraries/LibELF/Validation.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Libraries/LibELF/Validation.cpp b/Libraries/LibELF/Validation.cpp index 62229f923f..759ce24bc9 100644 --- a/Libraries/LibELF/Validation.cpp +++ b/Libraries/LibELF/Validation.cpp @@ -202,6 +202,12 @@ bool validate_program_headers(const Elf32_Ehdr& elf_header, size_t file_size, u8 dbgprintf("Possible shenanigans! Validating an ELF with executable stack.\n"); } break; + case PT_GNU_RELRO: + if ((program_header.p_flags & PF_X) && (program_header.p_flags & PF_W)) { + dbgprintf("SHENANIGANS! Program header %zu segment is marked write and execute\n", header_index); + return false; + } + break; default: // Not handling other program header types in other code so... let's not surprise them dbgprintf("Found program header (%zu) of unrecognized type %x!\n", header_index, program_header.p_type); |