aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/amd64
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2016-08-27 23:03:23 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2016-08-27 23:03:23 +0000
commitda6e468936ace83c59c3ee466ed93ede41850ec9 (patch)
tree71c0abadb9ad97fdc7174185151d5242a70a5465 /lib/libc/amd64
parent11d3ad2eab8e764510c299132015481f5ba72f29 (diff)
downloadsrc-da6e468936ace83c59c3ee466ed93ede41850ec9.tar.gz
src-da6e468936ace83c59c3ee466ed93ede41850ec9.zip
Do not obliterate errno value in the main thread during ptrace(2) call on x86.
Since ptrace(2) syscall can return -1 for non-error situations, libc wrappers set errno to 0 before performing the syscall, as the service to the caller. On both i386 and amd64, the errno symbol was directly referenced, which only works correctly in single-threaded process. Change assembler wrappers for ptrace(2) to get current thread errno location by calling __error(). Allow __error interposing, as currently allowed in cerror(). Sponsored by: The FreeBSD Foundation MFC after: 1 week
Notes
Notes: svn path=/head/; revision=304928
Diffstat (limited to 'lib/libc/amd64')
-rw-r--r--lib/libc/amd64/sys/ptrace.S10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S
index 9c4628da8ce4..c367a4ea12d1 100644
--- a/lib/libc/amd64/sys/ptrace.S
+++ b/lib/libc/amd64/sys/ptrace.S
@@ -38,14 +38,16 @@ __FBSDID("$FreeBSD$");
#include "SYS.h"
+ .globl CNAME(__error)
+ .type CNAME(__error),@function
+
ENTRY(ptrace)
- xorl %eax,%eax
#ifdef PIC
- movq PIC_GOT(CNAME(errno)),%r8
- movl %eax,(%r8)
+ callq PIC_PLT(CNAME(__error))
#else
- movl %eax,CNAME(errno)(%rip)
+ callq CNAME(__error)
#endif
+ movl $0,(%rax)
mov $SYS_ptrace,%eax
KERNCALL
jb HIDENAME(cerror)