summaryrefslogtreecommitdiff
path: root/Kernel/CoreDump.cpp
AgeCommit message (Collapse)Author
2021-08-23Everywhere: Core dump => CoredumpAndreas Kling
We all know what a coredump is, and it feels more natural to refer to it as a coredump (most code already does), so let's be consistent.
2021-08-22Kernel: Rename ScopedSpinlock => SpinlockLockerAndreas Kling
This matches MutexLocker, and doesn't sound like it's a lock itself.
2021-08-22Kernel: Rename SpinLock => SpinlockAndreas Kling
2021-08-10Kernel/SMP: Skip thread registers in core dump if there is no trap frameAndreas Kling
We can only get thread registers if there's a trap frame.
2021-08-07Kernel: Move SpinLock.h into Locking/Jean-Baptiste Boric
2021-08-06Kernel: Rename Process::space() => Process::address_space()Andreas Kling
We commonly talk about "a process's address space" so let's nudge the code towards matching how we talk about it. :^)
2021-08-06Kernel: Rename Kernel/VM/ to Kernel/Memory/Andreas Kling
This directory isn't just about virtual memory, it's about all kinds of memory management.
2021-08-06Kernel: Store coredump metadata properties as KStringsAndreas Kling
This patch also replaces the HashMap previously used to store coredump properties with a plain AK::Array.
2021-07-11Kernel: Rename VFS => VirtualFileSystemAndreas Kling
2021-07-07Kernel: Replace usage of LexicalPath with KLexicalPathMax Wipfli
This replaces all uses of LexicalPath in the Kernel with the functions from KLexicalPath. This also allows the Kernel to stop including AK::LexicalPath.
2021-06-29Kernel: Make sure JSON blobs in core dumps are correctly terminatedAndreas Kling
I regressed this in 648480f715180c92c467abf8477c4eb2675107b0. We have to make sure JsonObjectSerializer::finish() is called before writing out the blob. This is done automatically when the serializer is destroyed, so just wrap them in scopes.
2021-06-29Kernel: Use JsonObjectSerializer in the core dump generation codeAndreas Kling
2021-06-29Kernel+LibCoreDump: Implement more x86_64 coredump functionalityGunnar Beutner
2021-06-28Kernel+LibELF: Add support for validating and loading ELF64 executablesGunnar Beutner
2021-06-24Everywhere: Use nothrow new with `adopt_{ref,own}_if_nonnull`Daniel Bertalan
This commit converts naked `new`s to `AK::try_make` and `AK::try_create` wherever possible. If the called constructor is private, this can not be done, so we instead now use the standard-defined and compiler-agnostic `new (nothrow)`.
2021-05-30Kernel: Unnamed regions still need a null-terminator in core dumpsAndreas Kling
Fixes #7595.
2021-05-29Kernel: Make CoreDump::create API OOM safeBrian Gianforcaro
2021-05-28Kernel: Don't crash when writing a coredump with an unnamed regionGunnar Beutner
Previously we'd try to call ByteBuffer::append(nullptr, 1) when we came across a VM region that had no name.
2021-05-28Kernel: Use KString for Region namesAndreas Kling
Replace the AK::String used for Region::m_name with a KString. This seems beneficial across the board, but as a specific data point, it reduces time spent in sys$set_mmap_name() by ~50% on test-js. :^)
2021-04-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-18LibC+LibELF: Implement support for the dl_iterate_phdr helperGunnar Beutner
This helper is used by libgcc_s to figure out where the .eh_frame sections are located for all loaded shared objects.
2021-04-12Kernel: Replace process' regions vector with a Red Black treeIdan Horowitz
This should provide some speed up, as currently searches for regions containing a given address were performed in O(n) complexity, while this container allows us to do those in O(logn).
2021-03-28LibCoreDump+CrashDaemon: Compress coredumpsIdan Horowitz
Most coredumps contain large amounts of consecutive null bytes and as such are a prime candidate for compression. This commit makes CrashDaemon compress files once the kernel finishes emitting them, as well as adds the functionality needed in LibCoreDump to then parse them.
2021-02-28Kernel: Use default con/de-structorsBen Wiederhake
This may seem like a no-op change, however it shrinks down the Kernel by a bit: .text -432 .unmap_after_init -60 .data -480 .debug_info -673 .debug_aranges 8 .debug_ranges -232 .debug_line -558 .debug_str -308 .debug_frame -40 With '= default', the compiler can do more inlining, hence the savings. I intentionally omitted some opportunities for '= default', because they would increase the Kernel size.
2021-02-25Kernel: Fix some clang-tidy whines in CoreDumpAndreas Kling
2021-02-08Kernel: Reorganize ptrace implementation a bitAndreas Kling
The generic parts of ptrace now live in Kernel/Syscalls/ptrace.cpp and the i386 specific parts are moved to Arch/i386/CPU.cpp
2021-02-08Kernel: Factor address space management out of the Process classAndreas Kling
This patch adds Space, a class representing a process's address space. - Each Process has a Space. - The Space owns the PageDirectory and all Regions in the Process. This allows us to reorganize sys$execve() so that it constructs and populates a new Space fully before committing to it. Previously, we would construct the new address space while still running in the old one, and encountering an error meant we had to do tedious and error-prone rollback. Those problems are now gone, replaced by what's hopefully a set of much smaller problems and missing cleanups. :^)
2021-01-28Kernel: Generate coredump backtraces from "threads for coredump" listAndreas Kling
This broke with the change that gave each process a list of its own threads. Since threads are removed slightly earlier from that list during process teardown, we're not able to use it for generating coredump backtraces. Fortunately we have the "threads for coredump" list for just this purpose. :^)
2021-01-23Kernel: Create core dumps with S_IFREG set (regular file)Andreas Kling
Otherwise, the VFS will refuse to create the file.
2021-01-15Kernel: Store process arguments and environment in coredumpsLinus Groh
Currently they're only pushed onto the stack but not easily accessible from the Process class, so this adds a Vector<String> for both.
2021-01-15Kernel+LibELF+LibCoreDump+CrashReporter: Use JSON for ProcessInfoLinus Groh
This is in preparation of adding (much) more process information to coredumps. As we can only have one null-terminated char[] of arbitrary length in each struct it's now a single JSON blob, which is a great fit: easily extensible in the future and allows for key/value pairs and even nested objects, which will be used e.g. for the process environment, for example.
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2021-01-10Kernel+SystemServer+CrashDaemon: Better control where we put core dumpsAndreas Kling
SystemServer now creates the /tmp/coredump and /tmp/profiler_coredumps directories at startup, ensuring that they are owned by root, and with basic 0755 permissions. The kernel will also now refuse to put core dumps in a directory that doesn't fulfill the following criteria: - Owned by 0:0 - Directory with sticky bit not set - 0755 permissions Fixes #4435 Fixes #4850
2021-01-03Kernel+LibELF: Store termination signal in coredump ProcessInfoLinus Groh
2020-12-30Kernel: Embed a Metadata notes entry in coredumpsLinus Groh
2020-12-30Kernel: Embed a ProcessInfo notes entry in coredumpsLinus Groh
2020-12-27Kernel: CoreDump::write_program_headers: set NOTE p_memsz to p_fileszBrendan Coles
2020-12-27Kernel: Lock target process when generating core dumpAndreas Kling
Dumping core can happen at the end of a profiling run, and in that case we have to protect the target process and take the lock while iterating over its region map. Fixes #4509.
2020-12-25Kernel+LibC: Introduce a "dumpable" flag for processesAndreas Kling
This new flag controls two things: - Whether the kernel will generate core dumps for the process - Whether the EUID:EGID should own the process's files in /proc Processes are automatically made non-dumpable when their EUID or EGID is changed, either via syscalls that specifically modify those ID's, or via sys$execve(), when a set-uid or set-gid program is executed. A process can change its own dumpable flag at any time by calling the new sys$prctl(PR_SET_DUMPABLE) syscall. Fixes #4504.
2020-12-22Kernel: Abort core dump generation if any substep failsAndreas Kling
And make an effort to propagate errors out from the inner parts. This fixes an issue where the kernel would infinitely loop in coredump generation if the TmpFS filled up.
2020-12-21Everywhere: Switch from (void) to [[maybe_unused]] (#4473)Lenny Maiorani
Problem: - `(void)` simply casts the expression to void. This is understood to indicate that it is ignored, but this is really a compiler trick to get the compiler to not generate a warning. Solution: - Use the `[[maybe_unused]]` attribute to indicate the value is unused. Note: - Functions taking a `(void)` argument list have also been changed to `()` because this is not needed and shows up in the same grep command.
2020-12-15Kernel: Remove harmless OOB ELF header access in core dump generationAndreas Kling
2020-12-15Kernel: Don't take LexicalPath as argumentAndreas Kling
LexicalPath is a big and heavy class that's really meant as a helper for extracting parts of a path, not for storage or passing around. Instead, pass paths around as strings and use LexicalPath locally as needed.
2020-12-14Kernel: Pass full path of output coredump file to CoreDumpItamar
2020-12-14LibELF: Refactor coredump notes section structuresItamar
2020-12-14Kernel: Generate a coredump file when a process crashesItamar
When a process crashes, we generate a coredump file and write it in /tmp/coredumps/. The coredump file is an ELF file of type ET_CORE. It contains a segment for every userspace memory region of the process, and an additional PT_NOTE segment that contains the registers state for each thread, and a additional data about memory regions (e.g their name).