1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

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".
This commit is contained in:
Luke 2020-09-09 08:40:17 +01:00 committed by Andreas Kling
parent 9d8f1032b7
commit b3be275cf7

View file

@ -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);