svn commit: r364504 - stable/12/sys/amd64/linux
Edward Tomasz Napierala
trasz at FreeBSD.org
Sun Aug 23 19:20:39 UTC 2020
Author: trasz
Date: Sun Aug 23 19:20:38 2020
New Revision: 364504
URL: https://svnweb.freebsd.org/changeset/base/364504
Log:
MFC r347580:
Fix handling of r10 in Linux ptrace(2). This fixes decoding
of the 'flags' argument to mmap(2) with Linux strace(1).
Sponsored by: The FreeBSD Foundation
Modified:
stable/12/sys/amd64/linux/linux_ptrace.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/amd64/linux/linux_ptrace.c
==============================================================================
--- stable/12/sys/amd64/linux/linux_ptrace.c Sun Aug 23 19:19:00 2020 (r364503)
+++ stable/12/sys/amd64/linux/linux_ptrace.c Sun Aug 23 19:20:38 2020 (r364504)
@@ -338,18 +338,27 @@ linux_ptrace_getregs(struct thread *td, pid_t pid, voi
map_regs_to_linux(&b_reg, &l_reg);
- /*
- * The strace(1) utility depends on RAX being set to -ENOSYS
- * on syscall entry.
- */
error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo));
if (error != 0) {
printf("%s: PT_LWPINFO failed with error %d\n", __func__, error);
return (error);
}
- if (lwpinfo.pl_flags & PL_FLAG_SCE)
- l_reg.rax = -38; // XXX: Don't hardcode?
+ if (lwpinfo.pl_flags & PL_FLAG_SCE) {
+ /*
+ * The strace(1) utility depends on RAX being set to -ENOSYS
+ * on syscall entry; otherwise it loops printing those:
+ *
+ * [ Process PID=928 runs in 64 bit mode. ]
+ * [ Process PID=928 runs in x32 mode. ]
+ */
+ l_reg.rax = -38; /* -ENOSYS */
+ /*
+ * Undo the mangling done in exception.S:fast_syscall_common().
+ */
+ l_reg.r10 = l_reg.rcx;
+ }
+
error = copyout(&l_reg, (void *)data, sizeof(l_reg));
return (error);
}
@@ -399,21 +408,27 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid
map_regs_to_linux_regset(&b_reg, fsbase, gsbase, &l_regset);
- /*
- * The strace(1) utility depends on RAX being set to -ENOSYS
- * on syscall entry; otherwise it loops printing those:
- *
- * [ Process PID=928 runs in 64 bit mode. ]
- * [ Process PID=928 runs in x32 mode. ]
- */
error = kern_ptrace(td, PT_LWPINFO, pid, &lwpinfo, sizeof(lwpinfo));
if (error != 0) {
printf("%s: PT_LWPINFO failed with error %d\n",
__func__, error);
return (error);
}
- if (lwpinfo.pl_flags & PL_FLAG_SCE)
- l_regset.rax = -38; // XXX: Don't hardcode?
+ if (lwpinfo.pl_flags & PL_FLAG_SCE) {
+ /*
+ * The strace(1) utility depends on RAX being set to -ENOSYS
+ * on syscall entry; otherwise it loops printing those:
+ *
+ * [ Process PID=928 runs in 64 bit mode. ]
+ * [ Process PID=928 runs in x32 mode. ]
+ */
+ l_regset.rax = -38; /* -ENOSYS */
+
+ /*
+ * Undo the mangling done in exception.S:fast_syscall_common().
+ */
+ l_regset.r10 = l_regset.rcx;
+ }
len = MIN(iov.iov_len, sizeof(l_regset));
error = copyout(&l_regset, (void *)iov.iov_base, len);
More information about the svn-src-all
mailing list