-
Notifications
You must be signed in to change notification settings - Fork 388
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
Memory: Swap probe_read to kernel or user version #2213
Open
kevsecurity
wants to merge
11
commits into
main
Choose a base branch
from
pr/kevsecurity/add-probe-read-kernel-str
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
31f4c79
CRD: Add IsUserspaceData flag for args
kevsecurity 5fed43c
Tracing: Add UserspaceData flag to arg meta
kevsecurity 7d51904
Memory: Swap probe_read to kernel or user version
kevsecurity 0cb1f70
Memory: Add probe_read_kernel_or_user helpers
kevsecurity e1bcd2e
Memory: Update bpf_core_read.h
kevsecurity 4a2fe97
Memory: Add raw_syscall flag on arg meta
kevsecurity 9c4d85e
Memory: Use probe_read_kernel_or_user helpers
kevsecurity e2f0091
Retprobe: Use correct key for retprobe_map
kevsecurity 1bc49cd
Memory: Read kernel or user for return arguments
kevsecurity 70a327e
Memory: Add tail call to retkprobe
kevsecurity 179404a
Raw_syscalls: fix selector indices in policies
kevsecurity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ const ( | |
argReturnCopyBit = 1 << 4 | ||
argMaxDataBit = 1 << 5 | ||
argUserspaceDataBit = 1 << 6 | ||
argRawSyscallsBit = 1 << 7 | ||
) | ||
|
||
func argReturnCopy(meta int) bool { | ||
|
@@ -47,9 +48,10 @@ func argReturnCopy(meta int) bool { | |
// 4 : ReturnCopy | ||
// 5 : MaxData | ||
// 6 : UserspaceData | ||
// 7-15 : reserved | ||
// 7 : RawSyscalls | ||
// 8-15 : reserved | ||
// 16-31 : size for const_buf | ||
func getMetaValue(arg *v1alpha1.KProbeArg, userspaceDataDefault bool) (int, error) { | ||
func getMetaValue(arg *v1alpha1.KProbeArg, userspaceDataDefault bool, rawSyscalls bool) (int, error) { | ||
meta := 0 | ||
|
||
if arg.SizeArgIndex > 0 { | ||
|
@@ -75,6 +77,9 @@ func getMetaValue(arg *v1alpha1.KProbeArg, userspaceDataDefault bool) (int, erro | |
meta = meta | argUserspaceDataBit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
} | ||
} | ||
if rawSyscalls { | ||
meta = meta | argRawSyscallsBit | ||
} | ||
return meta, nil | ||
} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
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.
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.
Why do we need a different flag?
From what I can tell from the code the flag is used in
tetragon/bpf/process/types/basic.h
Lines 2697 to 2702 in 179404a
And set in
tetragon/pkg/sensors/tracing/generictracepoint.go
Line 251 in 179404a
Cant' we just do
And use only one flag?
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.
The idea was to prepare for being able to filter on arguments in raw_syscalls, and therefore arrays of arguments which could potentially be pointers. I thought it was a bit much to include that in this PR, but I was already thinking ahead for a following PR. Can do as you suggest if you prefer though.
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.
Thanks! I would prefer to keep the code as simple as possible, even if we end up extending this for filtering.
I've also thought about filtering
raw_syscalls
.One way would be to do as you suggest, and use the arguments but this seems tricky because we need to pass types for everything.
I think a better approach would be to do two-level filtering where we in
raw_syscall
event we to filter the type of the syscall and then we enable hooks on syscalls/ for filtering on the arguments. This seems simpler to me and it re-uses the arg filtering we already have. We would need to have a way to pass information from theraw_syscall
hook to the specific syscall hook, but we already have something similar Jiri's notify enforcer action.In any case, that's for another PR.