Prevent infinite userspace crash loops.

This commit is contained in:
4lDO2
2024-06-20 22:56:19 +02:00
parent 55fe58adf6
commit 7d5b2e6c21
5 changed files with 18 additions and 6 deletions
+2 -2
View File
@@ -203,8 +203,8 @@ pub struct Context {
pub struct SignalState {
/// Offset to jump to when a signal is received.
pub user_handler: NonZeroUsize,
/// Offset to jump to when a program fault occurs.
pub excp_handler: NonZeroUsize,
/// Offset to jump to when a program fault occurs. If None, the context is sigkilled.
pub excp_handler: Option<NonZeroUsize>,
/// Signal control pages, shared memory
pub thread_control: RaiiFrame,
+13
View File
@@ -48,4 +48,17 @@ pub fn signal_handler() {
.and_then(|_| ptrace::next_breakpoint().map(|f| f.contains(PTRACE_FLAG_IGNORE)));*/
}
pub fn excp_handler(signal: usize) {
let Ok(current) = context::current() else {
panic!("CPU exception but not inside of context! Trying to switch...");
};
let mut context = current.write();
let Some(eh) = context.sig.as_ref().and_then(|s| s.excp_handler) else {
context.being_sigkilled = true;
context::switch();
unreachable!();
};
// TODO
}