Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7]: src/lib/libc/arch/x86_64/sys Pull up following revision(s) (r...
details: https://anonhg.NetBSD.org/src/rev/0a66ba019604
branches: netbsd-7
changeset: 798625:0a66ba019604
user: martin <martin%NetBSD.org@localhost>
date: Tue Nov 25 15:07:37 2014 +0000
description:
Pull up following revision(s) (requested by christos in ticket #263):
lib/libc/arch/x86_64/sys/ptrace.S: revision 1.6
Fix ptrace %rcx corruption when pthread_errno() is used. Small example:
#include <sys/types.h>
#include <stdio.h>
#include <sys/ptrace.h>
int main(void) { ptrace(18, getpid(), NULL, 0xabcd); }
The -lpthread cases pases 0 instead of 0xabcd
diffstat:
lib/libc/arch/x86_64/sys/ptrace.S | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diffs (40 lines):
diff -r a4599c41a233 -r 0a66ba019604 lib/libc/arch/x86_64/sys/ptrace.S
--- a/lib/libc/arch/x86_64/sys/ptrace.S Tue Nov 25 14:53:23 2014 +0000
+++ b/lib/libc/arch/x86_64/sys/ptrace.S Tue Nov 25 15:07:37 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.S,v 1.5 2014/05/22 15:01:57 uebayasi Exp $ */
+/* $NetBSD: ptrace.S,v 1.5.2.1 2014/11/25 15:07:37 martin Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,7 +36,7 @@
#include <machine/asm.h>
#if defined(SYSLIBC_SCCS) && !defined(lint)
- RCSID("$NetBSD: ptrace.S,v 1.5 2014/05/22 15:01:57 uebayasi Exp $")
+ RCSID("$NetBSD: ptrace.S,v 1.5.2.1 2014/11/25 15:07:37 martin Exp $")
#endif /* SYSLIBC_SCCS and not lint */
#include "SYS.h"
@@ -44,12 +44,21 @@
.globl _C_LABEL(__errno)
ENTRY(ptrace)
+ /*
+ * The following code calls __errno() to set it to 0 before
+ * calling ptrace(2). The libc version of __errno() does not use
+ * any registers, but the libpthread version clobbers %rcx
+ * before we get a chance to store it in %r10. So we save it
+ * in %r10 and restore it.
+ */
+ movq %rcx, %r10
#ifdef __PIC__
call PIC_PLT(_C_LABEL(__errno))
#else
call _C_LABEL(__errno)
#endif /* __PIC__ */
movl $0,(%rax)
+ movq %r10, %rcx
SYSTRAP(ptrace)
jc err
ret
Home |
Main Index |
Thread Index |
Old Index