mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibELF+Kernel: Validate program headers in Image::parse
This should catch more malformed ELF files earlier than simply checking the ELF header alone. Also change the API of validate_program_headers to take the interpreter_path by pointer. This makes it less awkward to call when we don't care about the interpreter, and just want the validation.
This commit is contained in:
parent
8297698a3a
commit
3f808b0dda
5 changed files with 30 additions and 15 deletions
|
@ -402,7 +402,7 @@ KResultOr<NonnullRefPtr<FileDescription>> Process::find_elf_interpreter_for_exec
|
|||
|
||||
// Not using KResultOr here because we'll want to do the same thing in userspace in the RTLD
|
||||
String interpreter_path;
|
||||
if (!ELF::validate_program_headers(*elf_header, file_size, (u8*)first_page, nread, interpreter_path)) {
|
||||
if (!ELF::validate_program_headers(*elf_header, file_size, (u8*)first_page, nread, &interpreter_path)) {
|
||||
dbg() << "exec(" << path << "): File has invalid ELF Program headers";
|
||||
return KResult(-ENOEXEC);
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ KResultOr<NonnullRefPtr<FileDescription>> Process::find_elf_interpreter_for_exec
|
|||
|
||||
// Not using KResultOr here because we'll want to do the same thing in userspace in the RTLD
|
||||
String interpreter_interpreter_path;
|
||||
if (!ELF::validate_program_headers(*elf_header, interp_metadata.size, (u8*)first_page, nread, interpreter_interpreter_path)) {
|
||||
if (!ELF::validate_program_headers(*elf_header, interp_metadata.size, (u8*)first_page, nread, &interpreter_interpreter_path)) {
|
||||
dbg() << "exec(" << path << "): Interpreter (" << interpreter_description->absolute_path() << ") has invalid ELF Program headers";
|
||||
return KResult(-ENOEXEC);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue