arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone
Blob Blame History Raw
Note; the test is known to fail on the RHEL 7.7 kernel - the patch
fixes PT_GETREGS (which we want) but adds PTRACE_SINGLEBLOCK (which we
don't support yet).  So, the test case was not included.  - DJ

commit b08a6a0dea63742313ed3d9577c1e2d83436b196
Author: Stefan Liebler <stli@linux.vnet.ibm.com>
Date:   Mon Jun 19 16:27:25 2017 +0200

    S390: Sync ptrace.h with kernel. [BZ #21539]
    
    This patch removes PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS
    and PTRACE_SETFPREGS as these requests does not exist on s390 kernel.
    
    But the kernel has support for PTRACE_SINGLEBLOCK,
    PTRACE_SECCOMP_GET_FILTER, PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
    PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE and
    PTRACE_TE_ABORT_RAND.  Thus those are defined now.
    
    The current kernel s390 specific ptrace.h file also defines
    PTRACE_PEEKTEXT_AREA, PTRACE_PEEKDATA_AREA, PTRACE_POKETEXT_AREA,
    PTRACE_POKEDATA_AREA, PTRACE_PEEK_SYSTEM_CALL, PTRACE_POKE_SYSTEM_CALL
    and PTRACE_PROT, but those requests are not supported.
    Thus those defines are skipped in glibc ptrace.h.
    
    There were old includes of ptrace.h in sysdeps/s390/fpu/fesetenv.c.
    The ptrace feature isn't used there anymore, thus I removed the includes.
    
    Before this patch, <glibc>/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
    uses ptrace-request 12 for PTRACE_GETREGS,
    but <kernel>/include/uapi/linux/ptrace.h uses 12 for PTRACE_SINGLEBLOCK.
    
    The s390 kernel has never had support for PTRACE_GETREGS!
    Thus glibc ptrace.h is adjusted to match kernel ptrace.h.
    
    The new s390 specific test ensures, that PTRACE_SINGLEBLOCK defined
    in glibc works as expected.  If the kernel would interpret it as
    PTRACE_GETREGS, then the testcase will not make any progress
    and will time out.
    
    ChangeLog:
    
    	[BZ #21539]
    	* NEWS: Mention s390 ptrace request changes.
    	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
    	(PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS,
    	PTRACE_SETFPREGS): Remove enum constant.
    	(PT_GETREGS, PT_SETREGS, PT_GETFPREGS, T_SETFPREGS):
    	Remove defines.
    	(PTRACE_SINGLEBLOCK): New enum constant.
    	(PT_STEPBLOCK): New define.
    	(PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
    	PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE,
    	PTRACE_TE_ABORT_RAND): New enum constant and define.
    	* sysdeps/s390/fpu/fesetenv.c: Remove ptrace.h includes.
    	* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
    	New file.
    	* sysdeps/unix/sysv/linux/s390/Makefile: Add test.

diff --git a/sysdeps/s390/fpu/fesetenv.c b/sysdeps/s390/fpu/fesetenv.c
index 4c9bcf0..0f64a3f 100644
--- a/sysdeps/s390/fpu/fesetenv.c
+++ b/sysdeps/s390/fpu/fesetenv.c
@@ -20,8 +20,6 @@
 #include <fenv_libc.h>
 #include <fpu_control.h>
 #include <stddef.h>
-#include <asm/ptrace.h>
-#include <sys/ptrace.h>
 #include <unistd.h>
 
 int
diff --git a/sysdeps/unix/sysv/linux/s390/sys/ptrace.h b/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
index 7caf101..88079fc 100644
--- a/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
+++ b/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
@@ -89,25 +89,9 @@ enum __ptrace_request
   PTRACE_SINGLESTEP = 9,
 #define PT_STEP PTRACE_SINGLESTEP
 
-  /* Get all general purpose registers used by a processes.
-     This is not supported on all machines.  */
-   PTRACE_GETREGS = 12,
-#define PT_GETREGS PTRACE_GETREGS
-
-  /* Set all general purpose registers used by a processes.
-     This is not supported on all machines.  */
-   PTRACE_SETREGS = 13,
-#define PT_SETREGS PTRACE_SETREGS
-
-  /* Get all floating point registers used by a processes.
-     This is not supported on all machines.  */
-   PTRACE_GETFPREGS = 14,
-#define PT_GETFPREGS PTRACE_GETFPREGS
-
-  /* Set all floating point registers used by a processes.
-     This is not supported on all machines.  */
-   PTRACE_SETFPREGS = 15,
-#define PT_SETFPREGS PTRACE_SETFPREGS
+  /* Execute process until next taken branch.  */
+  PTRACE_SINGLEBLOCK = 12,
+#define PT_STEPBLOCK PTRACE_SINGLEBLOCK
 
   /* Attach to a process that is already running. */
   PTRACE_ATTACH = 16,
@@ -167,8 +151,26 @@ enum __ptrace_request
   PTRACE_SETSIGMASK = 0x420b,
 #define PTRACE_SETSIGMASK PTRACE_SETSIGMASK
 
-  PTRACE_SECCOMP_GET_FILTER = 0x420c
+  PTRACE_SECCOMP_GET_FILTER = 0x420c,
 #define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER
+
+  PTRACE_PEEKUSR_AREA = 0x5000,
+#define PTRACE_PEEKUSR_AREA PTRACE_PEEKUSR_AREA
+
+  PTRACE_POKEUSR_AREA = 0x5001,
+#define PTRACE_POKEUSR_AREA PTRACE_POKEUSR_AREA
+
+  PTRACE_GET_LAST_BREAK = 0x5006,
+#define PTRACE_GET_LAST_BREAK PTRACE_GET_LAST_BREAK
+
+  PTRACE_ENABLE_TE = 0x5009,
+#define PTRACE_ENABLE_TE PTRACE_ENABLE_TE
+
+  PTRACE_DISABLE_TE = 0x5010,
+#define PTRACE_DISABLE_TE PTRACE_DISABLE_TE
+
+  PTRACE_TE_ABORT_RAND = 0x5011
+#define PTRACE_TE_ABORT_RAND PTRACE_TE_ABORT_RAND
 };