Bug 469693

Summary: PTRACE_EVENT_CLONE not delivered when tracing system calls
Product: [Fedora] Fedora Reporter: Magnus Vesterlund <magnus_vesterlund>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: CLOSED WORKSFORME QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 16CC: dvlasenk, jan.kratochvil, kernel-maint, quintela
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-05 18:44:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test case
none
clone-test with a bit more verbose printout none

Description Magnus Vesterlund 2008-11-03 15:44:18 UTC
Created attachment 322319 [details]
Test case

Description of problem:

PTRACE_EVENT_CLONE notification not delivered to parent thread when tracing system calls with ptrace and PTRACE_O_TRACECLONE.

The attached test case spawns a child process that in turn spawns a child thread. The parent process traces system calls in the child process using PTRACE_SYSCALL and traces clones with PTRACE_O_TRACECLONE. When the child thread is create I expect the parent thread to get a SIGTRAP | (PTRACE_EVENT_CLONE << 8) signal and the child thread to get a SIGSTOP signal.

This is also what happens if I run the test case on a vanilla kernel (the 3057f wait status is the SIGTRAP | (PTRACE_EVENT_CLONE << 8), 137f is the SIGSTOP):

$ ./clone-test
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 857f
waitpid: 7523 -> 3057f
waitpid: 7524 -> 137f
waitpid: 7523 -> 857f
waitpid: 7524 -> 857f
waitpid: 7524 -> 857f
waitpid: 7523 -> 857f
waitpid: 7524 -> 0
waitpid: 7523 -> 0

However, when I run the program on the Fedora kernel the parent thread never gets its SIGTRAP | (PTRACE_EVENT_CLONE << 8) signal:

$ ./clone-test
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16658 -> 857f
waitpid: 16659 -> 137f
waitpid: 16659 -> 857f
waitpid: 16659 -> 857f
waitpid: 16659 -> 857f
waitpid: 16659 -> 0
waitpid: 16658 -> 857f
waitpid: 16658 -> 0

If don't trace system calls (use PTRACE_CONT instead of PTRACE_SYSCALL) the PTRACE_EVENT_CLONE notification is delivered as expected.


Version-Release number of selected component (if applicable):

kernel-2.6.26.6-79.fc9.x86_64
The FC10 beta kernels also have the same problem.

How reproducible:
Every time.

Steps to Reproduce:
1. Compile and run the attached program.

Actual results:
Parent thread does not get PTRACE_EVENT_CLONE notification.

Expected results:
Parent thread gets PTRACE_EVENT_CLONE notification.

Comment 1 Magnus Vesterlund 2008-11-04 10:03:55 UTC
kernel-2.6.26.6-49.fc8.x86_64 also has this problem.

Comment 2 Denys Vlasenko 2008-11-14 17:51:46 UTC
taking a look at this

Comment 3 Denys Vlasenko 2008-11-14 18:36:45 UTC
Added a bit more information in printf:

str1 = str2 = "";
if (status == 0) str1 = " EXIT_0";
if (WIFSTOPPED(status) && WSTOPSIG(status) == SIGSTOP) str1 = " STOP";
if (WIFSTOPPED(status) && WSTOPSIG(status) == (SIGTRAP | 0x80)) str1 = " TRAP_80";
if (((unsigned)status >> 16) == PTRACE_EVENT_CLONE) str2 = " EVENT_CLONE";
printf("waitpid: pid:%d status:%08x%s%s\n", tid, status, str1, str2);

Surprisingly, even on upstream 2.6.26.7 I see this:

waitpid: pid:8065 status:0000857f TRAP_80
....
waitpid: pid:8065 status:0000857f TRAP_80  <--- no EVENT_CLONE!?
waitpid: pid:8066 status:0000137f STOP
waitpid: pid:8066 status:0000857f TRAP_80
waitpid: pid:8066 status:0000857f TRAP_80
waitpid: pid:8066 status:0000857f TRAP_80
waitpid: pid:8066 status:00000000 EXIT_0
waitpid: pid:8065 status:0000857f TRAP_80
waitpid: pid:8065 status:0000857f TRAP_80
....
waitpid: pid:8065 status:0000857f TRAP_80
waitpid: pid:8065 status:00000000 EXIT_0

Comment 4 Denys Vlasenko 2008-11-14 18:56:48 UTC
On 2.6.27-rc6 it works as it should:

pid:3977 status:0000857f TRAP_80
...
pid:3977 status:0000857f TRAP_80
pid:3978 status:0000137f STOP
pid:3978 status:0000857f TRAP_80
pid:3978 status:0000857f TRAP_80
pid:3978 status:0000857f TRAP_80
pid:3978 status:00000000 EXIT_0
pid:3977 status:0003057f TRAP EVENT_CLONE
pid:3977 status:0000857f TRAP_80
...
pid:3977 status:0000857f TRAP_80
pid:3977 status:00000000 EXIT_0

This is non-utrace kernel. 2.6.26.7 in previous comment is IIRC with utrace enabled in .config.

So far looks like the problem exists in upstream utrace. Will retest better.
Will attach modified test now.

Comment 5 Denys Vlasenko 2008-11-14 18:57:33 UTC
Created attachment 323627 [details]
clone-test with a bit more verbose printout

Comment 6 Denys Vlasenko 2008-11-18 22:09:26 UTC
Added to

http://sourceware.org/systemtap/wiki/utrace/tests

as a "ptrace_event_clone" testcase

Comment 7 Denys Vlasenko 2009-01-14 13:30:21 UTC
kernel-2.6.29-0.28.rc1.fc11.x86_64 seems to have it fixed.

Comment 8 Bug Zapper 2009-06-10 03:10:01 UTC
This message is a reminder that Fedora 9 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 9.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '9'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 9's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 9 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 9 Bug Zapper 2009-07-14 14:36:02 UTC
Fedora 9 changed to end-of-life (EOL) status on 2009-07-10. Fedora 9 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 10 Denys Vlasenko 2012-01-05 18:20:34 UTC
Still happens on F16

Comment 11 Denys Vlasenko 2012-01-05 18:44:27 UTC
Er... no, it does not.
ptrace_event_clone.c testcase in ptrace-tests threw false positive on me.
I fixed the testcase.
Closing this bug.