fix: generate telemetry for host-mounted /sys/ paths in containers#2493
Open
asmit27rai wants to merge 5 commits intokubearmor:mainfrom
Open
fix: generate telemetry for host-mounted /sys/ paths in containers#2493asmit27rai wants to merge 5 commits intokubearmor:mainfrom
asmit27rai wants to merge 5 commits intokubearmor:mainfrom
Conversation
Signed-off-by: asmit27rai <raiasmit10@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a container has a host filesystem mount (e.g.,
/sys/kernel/security),accessing files on that mount generates no alerts or system logs.
Root Cause
In
KubeArmor/BPF/system_monitor.c, bothkprobe__openandkprobe__openatunconditionally dropped all file access events for paths starting with
/sys/via the
isSysDir()check. This was intended to reduce host-level sysfs noise,but it also silently dropped events from container processes accessing
host-mounted
/sys/paths.Without
save_args()being called in the kprobe, the corresponding kretprobe'sload_args()finds nothing → the event is never emitted → no telemetry.Fix
is_container_context()BPF helper that checkspid_ns != PROC_PID_INIT_INOto determine if the current processis running inside a container.
kprobe__openandkprobe__openatto only skip/sys/pathsfor host processes. Container processes now have their
/sys/accessevents flow through normally.
Fixes #1851