Skip to content

Commit 9d49f16

Browse files
committed
x86_64/sched: Sanitize sigreturn context
1 parent 047aa14 commit 9d49f16

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

kernel/src/arch/x86_64/sched.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,11 @@ pub(in crate::arch) fn restore_signal_frame(context: &mut Context) {
422422
// Restore the saved context.
423423
*context = frame.saved_context;
424424

425+
// Make sure the user doesn't do anything funky with the context.
426+
context.cs = offset_of!(Gdt, user_code64) as u64 | consts::CPL_USER as u64;
427+
context.ss = offset_of!(Gdt, user_data) as u64 | consts::CPL_USER as u64;
428+
context.rflags = (frame.saved_context.rflags & 0xDD5) | 0x202;
429+
425430
// Restore the signal mask.
426431
let task = Scheduler::get_current();
427432
let mut sig_state = task.signal.lock();

0 commit comments

Comments
 (0)