From 77651151f3caec7d2440404f8c0f1819757d1d5d Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sat, 24 Apr 2021 11:37:06 +0100 Subject: [PATCH] linux: make ptrace(2) return EIO when trying to peek invalid address Previously we've returned the error from native ptrace(2), ENOMEM. This confused Linux strace(2). Reviewed By: emaste Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29925 --- sys/amd64/linux/linux_ptrace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index 89fda7979359..76ad9b1e25c4 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -313,6 +313,8 @@ linux_ptrace_peek(struct thread *td, pid_t pid, void *addr, void *data) error = kern_ptrace(td, PT_READ_I, pid, addr, 0); if (error == 0) error = copyout(td->td_retval, data, sizeof(l_int)); + else if (error == ENOMEM) + error = EIO; td->td_retval[0] = error; return (error);