From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30240 invoked by alias); 13 Jun 2017 20:05:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 30223 invoked by uid 89); 13 Jun 2017 20:05:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Before, H*c:application X-HELO: vmicros1.altlinux.org Date: Tue, 13 Jun 2017 20:05:00 -0000 From: "Dmitry V. Levin" To: Stefan Liebler Cc: libc-alpha@sourceware.org, Carlos O'Donell Subject: Re: [PATCH] S390: Sync ptrace.h with kernel. [BZ #21539] Message-ID: <20170613200522.GA14306@altlinux.org> Mail-Followup-To: Stefan Liebler , libc-alpha@sourceware.org, Carlos O'Donell References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: X-SW-Source: 2017-06/txt/msg00574.txt.bz2 --/04w6evG8XlLl3ft Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 6211 On Tue, Jun 06, 2017 at 12:17:33PM +0200, Stefan Liebler wrote: [...] > diff --git a/sysdeps/unix/sysv/linux/s390/sys/ptrace.h b/sysdeps/unix/sys= v/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 =3D 9, > #define PT_STEP PTRACE_SINGLESTEP >=20=20 > - /* Get all general purpose registers used by a processes. > - This is not supported on all machines. */ > - PTRACE_GETREGS =3D 12, > -#define PT_GETREGS PTRACE_GETREGS > - > - /* Set all general purpose registers used by a processes. > - This is not supported on all machines. */ > - PTRACE_SETREGS =3D 13, > -#define PT_SETREGS PTRACE_SETREGS > - > - /* Get all floating point registers used by a processes. > - This is not supported on all machines. */ > - PTRACE_GETFPREGS =3D 14, > -#define PT_GETFPREGS PTRACE_GETFPREGS > - > - /* Set all floating point registers used by a processes. > - This is not supported on all machines. */ > - PTRACE_SETFPREGS =3D 15, > -#define PT_SETFPREGS PTRACE_SETFPREGS > + /* Execute process until next taken branch. */ > + PTRACE_SINGLEBLOCK =3D 12, > +#define PT_STEPBLOCK PTRACE_SINGLEBLOCK >=20=20 > /* Attach to a process that is already running. */ > PTRACE_ATTACH =3D 16, > @@ -167,8 +151,26 @@ enum __ptrace_request > PTRACE_SETSIGMASK =3D 0x420b, > #define PTRACE_SETSIGMASK PTRACE_SETSIGMASK >=20=20 > - PTRACE_SECCOMP_GET_FILTER =3D 0x420c > + PTRACE_SECCOMP_GET_FILTER =3D 0x420c, > #define PTRACE_SECCOMP_GET_FILTER PTRACE_SECCOMP_GET_FILTER > + > + PTRACE_PEEKUSR_AREA =3D 0x5000, > +#define PTRACE_PEEKUSR_AREA PTRACE_PEEKUSR_AREA > + > + PTRACE_POKEUSR_AREA =3D 0x5001, > +#define PTRACE_POKEUSR_AREA PTRACE_POKEUSR_AREA > + > + PTRACE_GET_LAST_BREAK =3D 0x5006, > +#define PTRACE_GET_LAST_BREAK PTRACE_GET_LAST_BREAK > + > + PTRACE_ENABLE_TE =3D 0x5009, > +#define PTRACE_ENABLE_TE PTRACE_ENABLE_TE > + > + PTRACE_DISABLE_TE =3D 0x5010, > +#define PTRACE_DISABLE_TE PTRACE_DISABLE_TE > + > + PTRACE_TE_ABORT_RAND =3D 0x5011 > +#define PTRACE_TE_ABORT_RAND PTRACE_TE_ABORT_RAND > }; The sys/ptrace.h part of the change looks fine. > diff --git a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c b/sysd= eps/unix/sysv/linux/s390/tst-ptrace-singleblock.c > new file mode 100644 > index 0000000..b384562 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c > @@ -0,0 +1,110 @@ > +/* Testing s390x PTRACE_SINGLEBLOCK ptrace request. > + Copyright (C) 2017 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Ensure that we use the PTRACE_SINGLEBLOCK definition from glibc ptrac= e.h > + in tracer_func. We need the kernel ptrace.h for structs ptrace_area > + and gregset_t. */ > +#include > +static const enum __ptrace_request req_singleblock =3D PTRACE_SINGLEBLOC= K; > +#include > + > +static void > +tracee_func (int pid) > +{ > + /* Dump the mapping information for manual inspection of the printed > + tracee addresses. */ > + char str[80]; > + sprintf (str, "cat /proc/%d/maps", pid); > + puts (str); > + system (str); > + fflush (stdout); > + > + ptrace (PTRACE_TRACEME); > + /* Stop tracee. Afterwards the tracer_func can operate. */ > + kill (pid, SIGSTOP); > + > + puts ("The PTRACE_SINGLEBLOCK of the tracer will stop after: " > + "brasl %r14,!"); > +} > + > +static void > +tracer_func (int pid) > +{ > + unsigned long last_break; > + ptrace_area parea; > + gregset_t regs; > + int status; > + > + while (1) > + { > + /* Wait for the tracee to be stopped or exited. */ > + wait (&status); > + if (WIFEXITED (status)) > + break; > + > + /* Get information about tracee: gprs, last breaking address. */ > + parea.len =3D sizeof (regs); > + parea.process_addr =3D (unsigned long) ®s; > + parea.kernel_addr =3D 0; > + ptrace (PTRACE_PEEKUSR_AREA, pid, &parea); Note that you can verify whether PTRACE_PEEKUSR_AREA has returned the expected result by comparing registers with those returned by PTRACE_GETREGSET. The latter is implemented on s390 since linux 2.6.27 so its use in glibc is safe. > + ptrace (PTRACE_GET_LAST_BREAK, pid, NULL, &last_break); As these ptrace calls are expected to succeed, you might want to check their return code. > + > + printf ("child IA: %p last_break: %p\n", > + (void *) regs[1], (void *) last_break); > + > + /* Execute tracee until next taken branch. > + > + Note: > + Before the commit which introduced this testcase, > + /sysdeps/unix/sysv/linux/s390/sys/ptrace.h > + uses ptrace-request 12 for PTRACE_GETREGS, > + but /include/uapi/linux/ptrace.h > + uses 12 for PTRACE_SINGLEBLOCK. > + > + The s390 kernel has no support for PTRACE_GETREGS! > + Thus glibc ptrace.h is adjusted to match kernel ptrace.h. > + > + This test ensures, that PTRACE_SINGLEBLOCK defined in glibc > + works as expected. If the kernel would interpret it as > + PTRACE_GETREGS, then the tracee will not make any progress > + and this testcase will time out. */ > + ptrace (req_singleblock, pid, NULL, NULL); Likewise. --=20 ldv --/04w6evG8XlLl3ft Content-Type: application/pgp-signature; name="signature.asc" Content-length: 801 -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJZQEWCAAoJEAVFT+BVnCUIidEQANzgo01unn4ZvaVt2L2JbWo8 CgWO00SFTjX0doQv8xZEGyMpX8I2MccilkZ03CsRn4hTA31Xa43fiMhxQCJF+2TJ WHWUtzjUq0ACIGj6GjZE3Ux/uSMwLiYNV+PLGd6h642dnJoKBlq+F/Mxi+XYVPjs GjT09wJBl6dE2g5uflRYdaBzPVCNPrxIi6gZ7kxvcl5i62cfl2VJna5eDRv5n0f8 mimR7Olwy2hQTVnnES7rp8NFpIvKjnkA9CxdeL6dGvhoQE6tt/nbnGyFpPVYnHnO X1XBNZFdFGjYRdmHFsQ4PCOS4HKPUv5q1no6dJvweTB6Grordzukj3wXh/I2drwR 7R9xFZRGvEqrBjDutUXA5nsPFquzbgcmpNpAzRM4QrvQLKh4IPGiDawU0XubsOX9 GosfhMmYCaOPyjesZulXlDIWZga9rXjFf+vn6J+rqgoISRLEGh99jjVyJrhtyMSz 1XNy2F5aX7qwNAM9FMZKgbWJp0FHJeVWHS/ADhbUH5NaU3qz+weVnTbDwvb4kZHm 4FJIjqwNiQcatrbcRPheg+JPy0Qi2UxPHs9K+3rie9UnHZvjW1PUqitDEqSJ/T4x GAAhw2GbCq002bEysoxtb6LN+Nsx1lDoJoFa6g2ztQlbQSVEilPggRh8z7v7f4N7 gQ6bOTX+bLVdOxj+gEyM =B2td -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--