mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Kernel: Add verification promise violations are propagated properly
This change adds a thread member variable to track if we have a pending promise violation on a kernel thread. This ensures that all code properly propagates promise violations up to the syscall handler. Suggested-by: Andreas Kling <kling@serenityos.org>
This commit is contained in:
parent
54b9a4ec1e
commit
018dc4bb5c
Notes:
sideshowbarker
2024-07-17 21:58:20 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/018dc4bb5ca Pull-request: https://github.com/SerenityOS/serenity/pull/11476
3 changed files with 12 additions and 1 deletions
|
@ -868,6 +868,7 @@ ErrorOr<void> Process::require_no_promises() const
|
|||
if (!has_promises())
|
||||
return {};
|
||||
dbgln("Has made a promise");
|
||||
Thread::current()->set_promise_violation_pending(true);
|
||||
return EPROMISEVIOLATION;
|
||||
}
|
||||
|
||||
|
@ -880,6 +881,7 @@ ErrorOr<void> Process::require_promise(Pledge promise)
|
|||
return {};
|
||||
|
||||
dbgln("Has not pledged {}", to_string(promise));
|
||||
Thread::current()->set_promise_violation_pending(true);
|
||||
(void)try_set_coredump_property("pledge_violation"sv, to_string(promise));
|
||||
return EPROMISEVIOLATION;
|
||||
}
|
||||
|
|
|
@ -235,8 +235,13 @@ NEVER_INLINE void syscall_handler(TrapFrame* trap)
|
|||
current_thread->die_if_needed();
|
||||
|
||||
// Crash any processes which have commited a promise violation during syscall handling.
|
||||
if (result.is_error() && result.error().code() == EPROMISEVIOLATION)
|
||||
if (result.is_error() && result.error().code() == EPROMISEVIOLATION) {
|
||||
VERIFY(current_thread->is_promise_violation_pending());
|
||||
current_thread->set_promise_violation_pending(false);
|
||||
process.crash(SIGABRT, 0);
|
||||
} else {
|
||||
VERIFY(!current_thread->is_promise_violation_pending());
|
||||
}
|
||||
|
||||
VERIFY(!g_scheduler_lock.is_locked_by_current_processor());
|
||||
}
|
||||
|
|
|
@ -1241,6 +1241,9 @@ public:
|
|||
bool is_profiling_suppressed() const { return m_is_profiling_suppressed; }
|
||||
void set_profiling_suppressed() { m_is_profiling_suppressed = true; }
|
||||
|
||||
bool is_promise_violation_pending() const { return m_is_promise_violation_pending; }
|
||||
void set_promise_violation_pending(bool value) { m_is_promise_violation_pending = value; }
|
||||
|
||||
String backtrace();
|
||||
|
||||
private:
|
||||
|
@ -1390,6 +1393,7 @@ private:
|
|||
bool m_in_block { false };
|
||||
bool m_is_idle_thread { false };
|
||||
bool m_is_crashing { false };
|
||||
bool m_is_promise_violation_pending { false };
|
||||
Atomic<bool> m_have_any_unmasked_pending_signals { false };
|
||||
Atomic<u32> m_nested_profiler_calls { 0 };
|
||||
|
||||
|
|
Loading…
Reference in a new issue