-
Notifications
You must be signed in to change notification settings - Fork 474
new: monitor only mode #4316
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
base: main
Are you sure you want to change the base?
new: monitor only mode #4316
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
kkourt
left a comment
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!
Left some comments, but LGTM.
f67e586 to
54304d1
Compare
kkourt
left a comment
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.
1 read-etc-passwd enabled 0 (global) generic_kprobe 1.87 MB monitor 0 0 0
One more comment: can we have monitor_only in the list?
Well, right now the because:
Do you think that, from an UX perspective, is it that bad not to expose |
I would say exposing MONITOR_ONY is good to have (but not too bad if we don't do it). |
Well i like this use of the new flag. I think it makes sense then, to have this check! Let me update the PR :) |
|
Pushed the changes @kkourt ! Also, updated PR description with an updated output from |
6ef3c44 to
4f01264
Compare
4f01264 to
0862044
Compare
0862044 to
288f179
Compare
|
Windows static checks CI is having some problems tracked here: #4330 |
kkourt
left a comment
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!
Please find some comments below.
| MonitorMode Mode = 1 | ||
| EnforceMode Mode = 0 | ||
| MonitorMode Mode = 1 | ||
| MonitorOnlyMode Mode = 2 // monitor and cannot be updated to enforce. Not visible to bpf. |
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.
Can you please add some information in the commit message for new(pkg/policyconf): introduce MonitorOnlyMode. on what is MonitorOnly mode and what is the motivation? I know it seems obvious now, but providing context is helpful both for people without the context we have now and also for our future selves.
Similarly for the other commits. Note that "why" we are doing something is equally (if not more) important that what. Usually, the what can be figured out by looking at the code, but the why is not so easy.
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.
I force-pushed the reworded commits; feel free to tell me if there's anything else that you feel like should be improved :)
| // state indicates the state of the collection | ||
| state TracingPolicyState | ||
| state TracingPolicyState | ||
| allowModeUpdate bool |
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.
Suggestion: How about we keep the mode here? That is, monitor, monitor_only, enforce.
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.
I think that using the ebpf map as source of truth is a good thing; i'd avoid storing that info bit in userspace.
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.
If we want the mode to be everywhere, we should really push it down to ebpf; lots of ugliness in this PR would go away then.
| if mode != policyconf.MonitorMode { | ||
| logger.GetLogger().Warn("monitor-only bit is set but bpf map is not in monitor mode", "policy", c.name) | ||
| } | ||
| return tetragon.TracingPolicyMode_TP_MODE_MONITOR_ONLY |
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.
comment: I wonder if we could return something else here if the mode is not monitor mode, but I don't have any good ideas. We can leave it as is and revisit as needed.
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.
I agree, don't really know what else to return :)
The new policyconf Mode will be used for policies that do not have any enforcement action. For those, nothing else but `monitor` mode should be available. The new mode is not exposed to ebpf (that will see `MonitorMode`), but is used in userspace to notify that the policy only supports monitoring. Also, add a small helper method `SupportEnforcement`. Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
It will be used by sensors `handler` to deny mode updates when `HasEnforcement` is false for all sensors in a collection. Signed-off-by: Federico Di Pierro <[email protected]>
In case all sensors in a collection do not support enforcement, deny any col.mode update. Signed-off-by: Federico Di Pierro <[email protected]>
When there are no enforcers, and no enforcement action nor override action, for all kinds of probes. Signed-off-by: Federico Di Pierro <[email protected]>
It will be exposed by the new `SensorIface::HasEnforcement()` API. Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
It will be returned by `collection.mode()` when `allowModeUpdate` is false. Signed-off-by: Federico Di Pierro <[email protected]> Co-authored-by: Kornilios Kourtis <[email protected]>
288f179 to
eaaa104
Compare
Description
Today, we default at
enforceeven for policies that do not support any enforcement.Introduce a
monitor_onlymode (that is userspace-only) that:monitorin ebpf map during startup to avoid falsely reportingenforceExample output:
Changelog