[PATCH] S390: Sync ptrace.h with kernel. [BZ #21539]

Stefan Liebler stli@linux.vnet.ibm.com
Fri Jul 7 10:22:00 GMT 2017


On 07/04/2017 05:37 PM, Stefan Liebler wrote:
> On 07/04/2017 11:41 AM, Florian Weimer wrote:
>> On 07/04/2017 10:22 AM, Stefan Liebler wrote:
>>> +      /* Ptrace request 12 is done with zero data argument:
>>> +     -If the kernel has support for PTRACE_SINGLEBLOCK (then the kernel
>>> +     header asm/ptrace.h defines this macro), the ptrace call is not 
>>> allowed
>>> +     to fail and has to continue the tracee until next taken branch.
>>
>> I think this is still bogus.  We can compile with newer kernel headers
>> than the host kernel, and this will cause the test to fail.
>>
>> Thanks,
>> Florian
>>
> 
> Okay.
> So I can check the return value of the second ptrace (req_singleblock, 
> pid, NULL, NULL) call at runtime to determine the kernel-support:
> 
>        errno = 0;
>        ret = ptrace (req_singleblock, pid, NULL, NULL);
>        if (ret == 0)
>      {
>        /* The kernel has support for PTRACE_SINGLEBLOCK ptrace request. */
>        TEST_VERIFY_EXIT (errno == 0);
>      }
>        else
>      {
>        /* The kernel (< 3.15) has no support for PTRACE_SINGLEBLOCK ptrace
>           request. */
>        TEST_VERIFY_EXIT (errno == EIO);
>        TEST_VERIFY_EXIT (ret == -1);
> 
>        /* Just continue tracee until it exits normally.  */
>        TEST_VERIFY_EXIT (ptrace (PTRACE_CONT, pid, NULL, NULL) == 0);
>      }
> 
> 
> 
> Then the test runs on kernels with / without support for 
> PTRACE_SINGLEBLOCK. The first ptrace call ensures that request 12 is not 
> interpreted as PTRACE_GETREGS.
> 
> Bye.
> Stefan
> 

Here is the complete patch with the change mentioned above.
Is this approach okay?

Bye.
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20170707_s390_ptrace_h.patch
Type: text/x-patch
Size: 4731 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170707/e498bb31/attachment.bin>


More information about the Libc-alpha mailing list