Bug 1780592

Summary: [RHEL 8] strace gets confused by PID namespaces
Product: Red Hat Enterprise Linux 8 Reporter: Edjunior Barbosa Machado <emachado>
Component: straceAssignee: Eugene Syromiatnikov <esyr>
strace sub component: system-version QA Contact: Edjunior Barbosa Machado <emachado>
Status: CLOSED DUPLICATE Docs Contact:
Severity: unspecified    
Priority: unspecified CC: berrange, emachado, esyr, law, lmiksik, mjw, mnewsome, mpetlan, ohudlick
Version: 8.2Keywords: Reopened
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1035434 Environment:
Last Closed: 2020-01-14 10:58:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1035434, 1804334, 1807458    
Bug Blocks: 1725113    

Description Edjunior Barbosa Machado 2019-12-06 13:43:17 UTC
Reproduced on RHEL-8.2 with:

strace-4.24-6.el8
kernel 4.18.0-159.el8
RHEL-8.2.0-20191203.0

+++ This bug was initially created as a clone of Bug #1035434 +++

Reproduced on RHEL-7 with

strace-4.8-3.el7
kernel-3.10.0-23.el7

+++ This bug was initially created as a clone of Bug #1035433 +++

Description of problem:
When using strace to debug an LXC problem I noticed that it gets a bit confused by PID namespaces.

I am running strace from host context, so I expect all PIDs it reports to be host PIDs. When strace creates new log files (due to the -ff CLI option) it names them based on the host PIDs, which is good. Inside these log files though the clone() syscalls are reporting container PIDs which is bad. This means you can't correlate the clone() syscalls  with the log files strace is creating.

If running strace from inside container context it correctly uses container PIDs in both places.

Version-Release number of selected component (if applicable):
strace-4.8-1.fc19.x86_64
kernel-3.11.9-200.fc19.x86_64

How reproducible:
Always

Steps to Reproduce:
1. From the host run

# strace -f -ff -o s.log unshare --pid -- /bin/sh

and at the shell prompt execute '/bin/sh' again. Then do it again. And again.. Then exit back to the host context

You should now have several log files
 

Actual results:
# ls s.log.*
s.log.9851  s.log.9860  s.log.9861  s.log.9862
# grep clone s.log.98*
s.log.9851:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fe81e7b6a10) = 9860
s.log.9860:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f47d93aca10) = 2
s.log.9861:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f9962d34a10) = 3


Expected results:
# ls s.log.*
s.log.9851  s.log.9860  s.log.9861  s.log.9862
# grep clone s.log.98*
s.log.9851:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fe81e7b6a10) = 9860
s.log.9860:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f47d93aca10) = 9861
s.log.9861:clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f9962d34a10) = 9862

Comment 2 Edjunior Barbosa Machado 2020-01-14 10:58:30 UTC

*** This bug has been marked as a duplicate of bug 1725113 ***