-
Notifications
You must be signed in to change notification settings - Fork 3.2k
policy: Fix potential nil pointer deref in selectorManager.GetSelections #27805
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
Merged
youngnick
merged 1 commit into
cilium:main
from
learnitall:pr/learnitall/fix-selectorcache-nil-deref
Sep 8, 2023
Merged
policy: Fix potential nil pointer deref in selectorManager.GetSelections #27805
youngnick
merged 1 commit into
cilium:main
from
learnitall:pr/learnitall/fix-selectorcache-nil-deref
Sep 8, 2023
+20
−1
Conversation
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
6d5b5c8
to
d58943c
Compare
d58943c
to
6c9a536
Compare
aditighag
approved these changes
Aug 31, 2023
/test |
This commit address the case in which `selectorManager.GetSelections` is called before `selectorManager.updateSelections` is called, which can cause a panic due to a nil pointer dereference in case the internal `selectorManager.selections` field is nil. To address this case, if the `selectorManager` has a nil value for its internal field `selections`, then `emptySelection` is returned. The reason `GetSelections` cannot modify the internal `selections` field if it sees that it is nil is because `selectorManager.setSelections` requires the managing `SelectorCache.mutex` to be locked. This cannot be guaranteed inside a call to `selectorManager.GetSelections`, which does not require locking. Signed-off-by: Ryan Drew <ryan.drew@isovalent.com>
6c9a536
to
364130c
Compare
/test |
This was referenced Oct 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
affects/v1.12
This issue affects v1.12 branch
affects/v1.13
This issue affects v1.13 branch
affects/v1.14
This issue affects v1.14 branch
backport-done/1.12
The backport for Cilium 1.12.x for this PR is done.
backport-done/1.13
The backport for Cilium 1.13.x for this PR is done.
backport-done/1.14
The backport for Cilium 1.14.x for this PR is done.
kind/bug
This is a bug in the Cilium logic.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
release-note/misc
This PR makes changes that have no direct user impact.
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.
Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXX
line if the commit addresses a particularGitHub issue.
Fixes: <commit-id>
tag, thenplease add the commit author[s] as reviewer[s] to this issue.
This commit address the case in which
selectorManager.GetSelections
is called beforeselectorManager.updateSelections
is called, which can cause a panic due to a nil pointer dereference in case the internalselectorManager.selections
field is nil. To address this case, if theselectorManager
has a nil value for its internal fieldselections
, thenemptySelection
is returned.The reason
GetSelections
cannot modify the internalselections
field if it sees that it is nil is becauseselectorManager.setSelections
requires the managingSelectorCache.mutex
to be locked. This cannot be guaranteed inside a call toselectorManager.GetSelections
, which does not require locking.This needs to be backported to 1.14, 1.1,3 and 1.12, please. Versions 1.13 and 1.12 will have a merge conflict due to changes made in commit 9397655, which adjusted how the atomic pointer is loaded. The needed change for these versions should look something like this: