Skip to content

Commit

Permalink
Merge pull request #111 from Freax13/enhancement/kill-exception-signal
Browse files Browse the repository at this point in the history
kill process when exception signal is already pending
  • Loading branch information
Freax13 authored Dec 31, 2024
2 parents a41a19d + 7d2c9a8 commit ce39a55
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tee/kernel/src/user/process/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Thread {
addr: self.cpu_state.lock().faulting_instruction(),
}),
};
assert!(self.queue_signal(sig_info));
self.queue_signal_or_die(sig_info);
}
Exit::Syscall(args) => self.clone().execute_syscall(args).await,
Exit::GeneralProtectionFault => {
Expand All @@ -244,7 +244,7 @@ impl Thread {
addr: self.cpu_state.lock().faulting_instruction(),
}),
};
assert!(self.queue_signal(sig_info));
self.queue_signal_or_die(sig_info);
}
Exit::PageFault(page_fault) => self.handle_page_fault(page_fault),
Exit::Timer => {
Expand Down Expand Up @@ -315,9 +315,7 @@ impl Thread {
addr: page_fault.addr,
}),
};
if !self.queue_signal(sig_info) {
self.process().exit_group(WStatus::signaled(Signal::SEGV));
}
self.queue_signal_or_die(sig_info);
}
}

Expand All @@ -329,6 +327,14 @@ impl Thread {
res
}

/// Try to queue a signal and kill the process if the signal is already pending.
pub fn queue_signal_or_die(&self, sig_info: SigInfo) {
if !self.queue_signal(sig_info) {
self.process()
.exit_group(WStatus::signaled(sig_info.signal));
}
}

async fn try_deliver_signal(self: &Arc<Self>) -> Result<()> {
self.process.wait_until_not_stopped().await;

Expand Down

0 comments on commit ce39a55

Please sign in to comment.