-
Notifications
You must be signed in to change notification settings - Fork 419
Bug(fix):-Prevent nil pointer crash during early SystemMonitor initialization #2298
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?
Conversation
Signed-off-by: Aryan-sharma11 <[email protected]> Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Aryan-sharma11 <[email protected]> Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Jones Jefferson <[email protected]> Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Jones Jefferson <[email protected]> Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Keshav Kapoor <[email protected]>
Signed-off-by: Keshav Kapoor <[email protected]>
rksharma95
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.
@keshav78-78 please rebase the PR. LGTM, just one comment inline.
| dm.Logger.Print("Initialized KubeArmor Monitor") | ||
|
|
||
| if dm.SystemMonitor != nil && dm.SystemMonitor.Logger != nil { | ||
| dm.SystemMonitor.Logger.ContainerNsKey = make(map[string]common.OuterKey) |
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 reported scenario (SystemMonitor == nil) could arise when both policy and hostpolicy are disabled (by default policy is enabled), in that case systemMonitor will not be initialized and will result in panic.
this fix looks good although we can safely remove if dm.SystemMonitor != nil && dm.SystemMonitor.Logger != nil as we're early returning if any of these case is true.
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 for the update — doing it in a moment. Will push the changes shortly.
Purpose of PR
Fixes #2297


This PR addresses a startup-time nil pointer dereference in
core/kubeArmor.go.The crash happens because
dm.SystemMonitor.Logger.ContainerNsKeyis initialized beforeSystemMonitorand itsLoggerare created.This caused consistent startup panics in:
Fix Implemented
Initialization is now performed after
InitSystemMonitor()succeeds, and additionally guarded by:This ensures safe access regardless of mode or degraded state.
Startup Stability
Error Resilience
Policy=falseorHostPolicy=falseMemory Overhead
Additional information for reviewer?
Checklist:
<type>(<scope>): <subject>