Kernel: Set "pledge_violation" coredump metadata in REQUIRE_PROMISE()

Similar to LibC storing an assertion message before aborting, process
death by pledge violation now sets a "pledge_violation" key with the
respective pledge name as value in its coredump metadata, which the
CrashReporter will then show.
This commit is contained in:
Linus Groh 2021-01-20 20:10:13 +01:00 committed by Andreas Kling
parent 7e5c49b755
commit 678919e9c1
Notes: sideshowbarker 2024-07-18 23:02:10 +09:00
2 changed files with 6 additions and 0 deletions

View file

@ -499,6 +499,7 @@ public:
void unblock_waiters(Thread::WaitBlocker::UnblockFlags, u8 signal = 0);
Thread::WaitBlockCondition& wait_block_condition() { return m_wait_block_condition; }
HashMap<String, String>& coredump_metadata() { return m_coredump_metadata; }
const HashMap<String, String>& coredump_metadata() const { return m_coredump_metadata; }
PerformanceEventBuffer* perf_events() { return m_perf_event_buffer; }
@ -778,6 +779,8 @@ inline u32 Thread::effective_priority() const
&& !Process::current()->has_promised(Pledge::promise)) { \
dbgln("Has not pledged {}", #promise); \
cli(); \
Process::current()->coredump_metadata().set( \
"pledge_violation", #promise); \
Process::current()->crash(SIGABRT, 0); \
ASSERT_NOT_REACHED(); \
} \

View file

@ -57,6 +57,8 @@ struct [[gnu::packed]] ProcessInfo {
// - "pid" (int)
// - "termination_signal" (u8)
// - "executable_path" (String)
// - "arguments" (Vector<String>)
// - "environment" (Vector<String>)
char json_data[]; // Null terminated
};
@ -91,6 +93,7 @@ struct [[gnu::packed]] Metadata {
//
// Well-known keys:
// - "assertion": Used by LibC's __assertion_failed() to store assertion info
// - "pledge_violation": Used by the Kernel's REQUIRE_PROMISE() to store pledge violation info
char json_data[]; // Null terminated
};