kernel: Mask away unsafe bits in rflags when restoring state after a signal
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-07-15 11:54:48 +02:00
parent 89786d8be2
commit f9003d7a58
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -150,6 +150,8 @@ void Thread::sigreturn(Registers* current_regs)
{
memcpy(&regs, current_regs, sizeof(regs));
u64 rflags = current_regs->rflags;
u64 rsp;
pop_mem_from_stack((u8*)&rsp, sizeof(rsp));
regs.rsp = rsp;
@ -159,8 +161,7 @@ void Thread::sigreturn(Registers* current_regs)
memcpy(&regs, current_regs, sizeof(regs));
regs.cs = 0x18 | 3;
regs.ss = 0x20 | 3;
// FIXME: Using this, a program can craft a special RFLAGS that gives them a higher IOPL or other stuff. Find out
// exactly what bits to block from modifying.
regs.rflags = (rflags & ~0xdff) | (regs.rflags & 0xdff);
fp_data.restore();