summaryrefslogtreecommitdiff
path: root/Libraries/LibELF/ELFLoader.cpp
AgeCommit message (Collapse)Author
2020-04-11LibELF: Move ELF classes into namespace ELFAndrew Kaster
This is for consistency with other namespace changes that were made a while back to the other libraries :)
2020-04-11LibELF: Add a find_symbol() API that finds a Symbol for an addressAndreas Kling
Also add ELFImage::Symbol::raw_data() to get a StringView containing the entire symbol contents.
2020-04-07LibELF: Cache symbol counts + demangled names (userspace only)Andreas Kling
To make repeated symbolication requests faster, we now cache the symbol count on ELFLoader instead of looking it up in the image each time. We also cache the demangled versions of names after looking them up the first time. This is a huge speedup for ProfileViewer. :^)
2020-03-08Userspace: Add missing #includes now that AK/StdLibExtras.h is smallerAndreas Kling
2020-03-03AK: Make quick_sort() a little more ergonomicAndreas Kling
Now it actually defaults to "a < b" comparison, instead of forcing you to provide a trivial less-than comparator. Also you can pass in any collection type that has .begin() and .end() and we'll sort it for you.
2020-02-19LibELF: Short-circuit symbolication when there are no symbolsAndreas Kling
2020-02-16Kernel: Move all code into the Kernel namespaceAndreas Kling
2020-02-10AK: Remove bitrotted Traits::dump() mechanismAndreas Kling
This was only used by HashTable::dump() which I used when doing the first HashTable implementation. Removing this allows us to also remove most includes of <AK/kstdio.h>.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-16Kernel+LibELF: Don't blindly trust ELF symbol offsets in symbolicationAndreas Kling
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
2020-01-13LibELF: Add methods to validate the ELF and program headersAndrew Kaster
These will make sure there's no funny business or funny offsets in the main ELF header or each Program Header. More can still be done (like validating section headers), but this is a good start
2020-01-10Kernel+LibELF: Enable SMAP protection during non-syscall exec()Andreas Kling
When loading a new executable, we now map the ELF image in kernel-only memory and parse it there. Then we use copy_to_user() when initializing writable regions with data from the executable. Note that the exec() syscall still disables SMAP protection and will require additional work. This patch only affects kernel-originated process spawns.
2020-01-06Kernel+LibELF: Validate PT_LOAD and PT_TLS offsets before memcpy()'ingAndreas Kling
Before this, you could make the kernel copy memory from anywhere by setting up an ELF executable with a program header specifying file offsets outside the file. Since ELFImage didn't even know how large it was, we had no clue that we were copying things from outside the ELF. Fix this by adding a size field to ELFImage and validating program header ranges before memcpy()'ing to them. The ELF code is definitely going to need more validation and checking.
2019-12-25Kernel: Make kernel memory regions be non-executable by defaultAndreas Kling
From now on, you'll have to request executable memory specifically if you want some.
2019-12-12Kernel: Separate out the symbol offsets in profile outputAndreas Kling
Instead of saying "main +39" and "main +57" etc, we now have a separate field in /proc/profile for the offset-into-the-symbol.
2019-11-29Kernel: Demangle kernel C++ symbols correctly againAndreas Kling
I broke this while implementing module linking. Also move the actual demangling work to AK, in AK::demangle(const char*)
2019-11-27Kernel: Demangle userspace ELF symbols in backtracesAndreas Kling
Turns out we can use abi::__cxa_demangle() for this, and all we need to provide is sprintf(), realloc() and free(), so this patch exposes them. We now have fully demangled C++ backtraces :^)
2019-11-06LibELF: Move AK/ELF/ into Libraries/LibELF/Andreas Kling
Let's arrange things like this instead. It didn't feel right for all of the ELF handling code to live in AK.