mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 06:55:07 +00:00
Lagom+LibELF: Add an ELF fuzzer, and tweak the code to survive a few minutes of fuzzing (#3071)
If a buffer smaller than Elf32_Ehdr was passed to Image, header() would do an out-of-bounds read. Make parse() check for that. Make most Image methods assert that the image is_valid(). For that to work, set m_valid early in Image::parse() instead of only at its end. Also reorder a few things so that the fuzzer doesn't hit (valid) assertions, which were harmless from a security PoV but which still allowed userspace to crash the kernel with an invalid ELF file. Make dbgprintf()s configurable at run time so that the fuzzer doesn't produce lots of logspam.
This commit is contained in:
parent
eaf7e68408
commit
00f658b984
8 changed files with 123 additions and 39 deletions
|
@ -40,10 +40,9 @@
|
|||
|
||||
namespace ELF {
|
||||
|
||||
Loader::Loader(const u8* buffer, size_t size)
|
||||
: m_image(buffer, size)
|
||||
Loader::Loader(const u8* buffer, size_t size, bool verbose_logging)
|
||||
: m_image(buffer, size, verbose_logging)
|
||||
{
|
||||
m_symbol_count = m_image.symbol_count();
|
||||
}
|
||||
|
||||
Loader::~Loader()
|
||||
|
@ -58,6 +57,8 @@ bool Loader::load()
|
|||
if (!m_image.is_valid())
|
||||
return false;
|
||||
|
||||
m_symbol_count = m_image.symbol_count();
|
||||
|
||||
if (!layout())
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue