tetragon: Add missing setup for matchParentBinaries selector#4888
Draft
olsajiri wants to merge 6 commits into
Draft
tetragon: Add missing setup for matchParentBinaries selector#4888olsajiri wants to merge 6 commits into
olsajiri wants to merge 6 commits into
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
0859862 to
d304ae9
Compare
a630c2d to
6950d68
Compare
Tracing sensors (kprobe, lsm, uprobe, usdt, tracepoint) include pfilter.h which references the PARENTS_MAP_ENABLED rodata constant to gate parent-binary selector matching in BPF. The constant was only set for the execve program in pkg/sensors/base/base.go, leaving it at zero in all tracing sensors even when --parents-map-enabled is set. Add setParentsMap() helper in generic.go that both appends the ParentBinariesMap to the sensor's map list and rewrites PARENTS_MAP_ENABLED=1 in every program's rodata. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Add TestMatchParentBinariesSetParentsMap to verify that sensor construction correctly sets PARENTS_MAP_ENABLED in RewriteConstants and includes ParentBinariesMap in the sensor maps when ParentsMapEnabled is enabled, and does neither when it is disabled. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Add WithSetup() on the Builder that registers a function to run before the observer is loaded. The returned cleanup function, if non-nil, is called after the test completes. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Truncate the export file before each scenario (after the first) so each scenario's event checker sees a clean stream without leftover events from previous scenarios. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Currently the observer is created with WithMyPid() option, which means all events must originate in observer's family (which means observer itself or its kids). This filter does not work reliably when we have multiple descendants, and events comes from deepest kid first, which is case for test coming in following changes. The WithAllEvents hook creates observer without WithMyPid() option. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Add TestMatchParentBinariesKprobePolicytest that loads a kprobe policy with matchParentBinaries selector and verifies the BPF filter in two scenarios: - lseek-pipe run via bash parent: events arrive (selector matches) - lseek-pipe run via sh parent: no events arrive (selector filters out) The test uses WithAllEvents hook, because I saw observer with WithMyPid() option failing on it. The debug showed that the pidset filter won't work properly when the deepest kid generated the event first. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
6950d68 to
5ac7893
Compare
Contributor
|
Oh, didnt notice that.. thanks! |
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.
Tracing sensors (kprobe, lsm, uprobe, usdt, tracepoint) include
pfilter.h which references the PARENTS_MAP_ENABLED rodata constant to
gate parent-binary selector matching in BPF. The constant was only set
for the execve program in pkg/sensors/base/base.go, leaving it at zero
in all tracing sensors even when --parents-map-enabled is set.