-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update(userspace/libsinsp): rely on proc root for user and group container lookup #803
update(userspace/libsinsp): rely on proc root for user and group container lookup #803
Conversation
…ainer lookup Instead of checking /proc/<pid>/ns/mnt, just check /proc/<pid>/root inode. The mount namespace gets created before the process actually gets into that namespace, so it was flaky and we also had a workaround getting it to work only for containers being created with non-root user. Signed-off-by: Angelo Puglisi <[email protected]>
Signed-off-by: Angelo Puglisi <[email protected]>
Signed-off-by: Angelo Puglisi <[email protected]>
I saw that, thank you very much! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work and simplification!
/approve
LGTM label has been added. Git tree hash: 5aeb70c7ebe6c16b76c36c56a8d3fd8a496966df
|
/milestone 0.11.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
LGTM, but I have a few questions:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, deepskyblue86, FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
hold this until all doubts are solved |
That test was already failing from time to time (e.g. https://github.com/falcosecurity/libs/actions/runs/3563324665/jobs/5985981759).
From my tests Specifically about this:
{"container.id":"c650ae1b4fd7","evt.args":"res=0 exe=runc args=init. tid=5394(6) pid=5394(6) ptid=5389(runc) cwd= fdlimit=1048576 pgft_maj=0 pgft_min=348 vm_size=9816 vm_rss=4 vm_swap=0 comm=6 cgroups=cpuset=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.cpu=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.cpuacct=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.io=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.memory=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4. env=GOMAXPROCS=4._LIBCONTAINER_INITPIPE=3._LIBCONTAINER_STATEDIR=/var/run/docker/runtime-runc/moby/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4._LIBCONTAINER_LOGPIPE=4._LIBCONTAINER_LOGLEVEL=4._LIBCONTAINER_FIFOFD=5._LIBCONTAINER_INITTYPE=standard._LIBCONTAINER_CLONED_BINARY=1. tty=0 pgid=5376(containerd-shim) loginuid=-1 flags=1(EXE_WRITABLE) cap_inheritable=0 cap_permitted=3FFFFFFFFF cap_effective=3FFFFFFFFF ","evt.category":"process","evt.type":"execve","group.gid":0,"group.name":"root","proc.cmdline":"6 init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"flags=248(CLONE_NEWIPC|CLONE_NEWNET|CLONE_NEWNS|CLONE_NEWPID|CLONE_NEWUTS) ","evt.category":"process","evt.type":"unshare","group.gid":0,"group.name":"root","proc.cmdline":"runc:[0:PARENT] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"res=0 ","evt.category":"process","evt.type":"unshare","group.gid":0,"group.name":"root","proc.cmdline":"runc:[0:PARENT] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"uid=0(<NA>) ","evt.category":"user","evt.type":"setuid","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"res=0 ","evt.category":"user","evt.type":"setuid","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"","evt.category":"unknown","evt.type":"pivot_root","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"","evt.category":"unknown","evt.type":"pivot_root","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"uid=0(<NA>) ","evt.category":"user","evt.type":"setuid","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"res=0 ","evt.category":"user","evt.type":"setuid","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"filename=/bin/sh ","evt.category":"process","evt.type":"execve","group.gid":0,"group.name":"root","proc.cmdline":"runc:[1:CHILD] init","user.name":"root","user.uid":0}
{"container.id":"c650ae1b4fd7","evt.args":"res=0 exe=sh args=-c.exit. tid=5396(sh) pid=5396(sh) ptid=5376(containerd-shim) cwd= fdlimit=1048576 pgft_maj=0 pgft_min=483 vm_size=1520 vm_rss=4 vm_swap=0 comm=sh cgroups=cpuset=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.cpu=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.cpuacct=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.io=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4.memory=/docker/c650ae1b4fd7cc661633a8a9535c74cfbab331313f5ff161a92b6c19081195d4. env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin.HOSTNAME=c650ae1b4fd7.NGINX_VERSION=1.14.2.HOME=/root. tty=0 pgid=1(systemd) loginuid=-1 flags=1(EXE_WRITABLE) cap_inheritable=0 cap_permitted=A80425FB cap_effective=A80425FB ","evt.category":"process","evt.type":"execve","group.gid":0,"group.name":"root","proc.cmdline":"sh -c exit","user.name":"root","user.uid":0} I think we are. |
Hmm okay. I wonder if this PR makes it stable though.
(...)
Perfect. So we have an explanation and a patch. SHIP IT! ;) |
/unhold |
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Instead of checking /proc//ns/mnt, just check /proc//root inode. The mount namespace gets created before the process actually gets into that namespace, so it was flaky and we also had a workaround getting it to work only for containers being created with non-root user.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: