Kernel: Fix usermode verification in ptrace with PT_SETREGS

When doing PT_SETREGS, we want to verify that the debugged thread is
executing in usermode.

b2f7ccf refactored things and flipped the relevant check around, which
broke things that use PT_SETREGS (for example, stepping over
breakpoints with sdb).
This commit is contained in:
Itamar 2023-02-03 16:22:16 +02:00 committed by Jelle Raaijmakers
parent 85ca19ffd5
commit 8fce807b10
Notes: sideshowbarker 2024-07-17 05:02:42 +09:00

View file

@ -107,7 +107,7 @@ static ErrorOr<FlatPtr> handle_ptrace(Kernel::Syscall::SC_ptrace_params const& p
auto& peer_saved_registers = peer->get_register_dump_from_stack();
// Verify that the saved registers are in usermode context
if (peer_saved_registers.previous_mode() == ExecutionMode::User)
if (peer_saved_registers.previous_mode() != ExecutionMode::User)
return EFAULT;
tracer->set_regs(regs);