Skip to content

Commit

Permalink
kill process when exception signal is already pending
Browse files Browse the repository at this point in the history
  • Loading branch information
Freax13 committed Dec 31, 2024
1 parent 4078d38 commit 7d2c9a8
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 @@ -232,7 +232,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 @@ -243,7 +243,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 @@ -314,9 +314,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 @@ -328,6 +326,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 7d2c9a8

Please sign in to comment.