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 Additional info:
This message is a notice that Fedora 19 is now at end of life. Fedora has stopped maintaining and issuing updates for Fedora 19. It is Fedora's policy to close all bug reports from releases that are no longer maintained. Approximately 4 (four) weeks from now this bug will be closed as EOL if it remains open with a Fedora 'version' of '19'. 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. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 19 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, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. 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.
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 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. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
(In reply to Daniel Berrange from comment #0) > I am running strace from host context, so I expect all PIDs it reports to be > host PIDs. To be honest, I don't understand why do you have such expectations. strace traditionally prints these numbers as they are written by the kernel and seen in userspace. Even if such a translation from tracee namespace to strace namespace was possible, wouldn't it be an additional source of confusion? If implemented, I wouldn't enable any pid/uid/whatever namespace translation by default.
(In reply to Dmitry V. Levin from comment #3) > (In reply to Daniel Berrange from comment #0) > > I am running strace from host context, so I expect all PIDs it reports to be > > host PIDs. > > To be honest, I don't understand why do you have such expectations. > strace traditionally prints these numbers as they are written by the kernel > and seen in userspace. Even if such a translation from tracee namespace to > strace namespace was possible, wouldn't it be an additional source of > confusion? > > If implemented, I wouldn't enable any pid/uid/whatever namespace translation > by default. Well as I said, my strace binary is in the host namespace, so I expect data it prints to be related to the host namespace. This lets me then use that PID with other tools also running from that same shell session in the host namespace. There's no indication that the PID it prints is from the child namespace, so that is confusing as is and not helpeful when trying to correlate with data seen from other debugging tools in that host session. If I were running strace binary inside the child namespace, then i'd expect data it prints to be related to this child namespace, so it matches data from other tools run in that child namespace.
(In reply to Daniel Berrange from comment #4) > Well as I said, my strace binary is in the host namespace, so I expect data > it prints to be related to the host namespace. This lets me then use that > PID with other tools also running from that same shell session in the host > namespace. There's no indication that the PID it prints is from the child > namespace, so that is confusing as is and not helpeful when trying to > correlate with data seen from other debugging tools in that host session. > > If I were running strace binary inside the child namespace, then i'd expect > data it prints to be related to this child namespace, so it matches data > from other tools run in that child namespace. Should the same apply for other kinds of namespaces (user, chroot)? Do you have an idea how to retrieve such information? As I understood, one should construct the hierarchy of PID namespaces (using the technique similar to described in [1]) in order to interpret the values in /proc/pid/status, and then scan all /proc/pid/status files (assuming that it is mounted by a process with the same PID namespace as strace has) in order to find the required PID in the required PID NS, is that correct? And this information can't be cached, as it may change between calls, right? [1] http://blog.man7.org/2016/12/introspecting-namespace-relationships.html
FEDORA-2020-630310d1cb has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-630310d1cb
FEDORA-2020-c36a7dcfbc has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-c36a7dcfbc
FEDORA-2020-bf724fd128 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-bf724fd128
FEDORA-2020-bf724fd128 has been pushed to the Fedora 32 stable repository. If problem still persists, please make note of it in this bug report.
FEDORA-2020-c36a7dcfbc has been pushed to the Fedora 31 stable repository. If problem still persists, please make note of it in this bug report.
FEDORA-2020-630310d1cb has been pushed to the Fedora 33 stable repository. If problem still persists, please make note of it in this bug report.