Prevent infinite userspace crash loops.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user