mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 03:08:11 +00:00
Kernel+LibELF: Don't blindly trust ELF symbol offsets in symbolication
It was possible to craft a custom ELF executable that when symbolicated would cause the kernel to read from user-controlled addresses anywhere in memory. You could then fetch this memory via /proc/PID/stack We fix this by making ELFImage hand out StringView rather than raw const char* for symbol names. In case a symbol offset is outside the ELF image, you get a null StringView. :^) Test: Kernel/elf-symbolication-kernel-read-exploit.cpp
This commit is contained in:
parent
60143c8d4e
commit
c6e552ac8f
9 changed files with 140 additions and 24 deletions
|
@ -113,7 +113,7 @@ char* ELFLoader::symbol_ptr(const char* name)
|
|||
m_image.for_each_symbol([&](const ELFImage::Symbol symbol) {
|
||||
if (symbol.type() != STT_FUNC)
|
||||
return IterationDecision::Continue;
|
||||
if (strcmp(symbol.name(), name))
|
||||
if (symbol.name() == name)
|
||||
return IterationDecision::Continue;
|
||||
if (m_image.is_executable())
|
||||
found_ptr = (char*)(size_t)symbol.value();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue