Kernel: Fix little mistakes in ptrace(PT_PEEK)

Output address validation should be done for the tracer's address space
and not the tracee's.

Also use copy_to_user() instead of copy_from_user(). The two are really
identical at the moment, but maybe we can add some assertions to make
sure we're doing what we think we're doing.

Thanks to Sergey for spotting these!
This commit is contained in:
Andreas Kling 2020-04-14 09:41:49 +02:00
parent f0fd85dc1b
commit 0440f4f257
Notes: sideshowbarker 2024-07-19 07:36:51 +09:00

View file

@ -113,9 +113,9 @@ KResultOr<u32> handle_syscall(const Kernel::Syscall::SC_ptrace_params& params, P
auto result = peer->process().peek_user_data(peek_params.address);
if (result.is_error())
return -EFAULT;
if (!peer->process().validate_write(peek_params.out_data, sizeof(u32)))
if (!caller.validate_write(peek_params.out_data, sizeof(u32)))
return -EFAULT;
copy_from_user(peek_params.out_data, &result.value());
copy_to_user(peek_params.out_data, &result.value());
break;
}