-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
endpoint: Do not override deny entries with proxy redirects #26344
Merged
borkmann
merged 2 commits into
cilium:main
from
jrajahalme:policy-deny-override-redirect
Jul 6, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
It seems to me like this line was intended to try to protect against this case previously, but it relies on the desired
mapstate
while iterating the L4 filters, which I guess is insufficient in this case for some reason? Do we still need this check? I find it a bit confusing that the reader cannot make assumptions about whether the traffic is allowed after this line:cilium/pkg/endpoint/bpf.go
Line 230 in 3fc1e87
Walking back up the stack to
runPreCompilationSteps()
, it seems to me that the desired policy map should be populated with the content to be able to allow the above check to protect against this condition already.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.
Ah, I see that this patch now adds the comment inside this function to state:
but I don't quite understand, is it not possible to make a clear call about whether this L4 filter is allowed using the map state? Is that because the L4 filter may contain a range of L3 peers or even the "any" L3 peer (ie, L4-only rule/filter), and as such we can't make a generic deny query into the mapstate without iterating the L4 filter's L3 peers and resolving those against a selectorcache for the real identities?
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.
At best it is definitely misleading to see
!mapState.AllowsL4(...)
and it turns out that actually the mapState may still disallow the L4 peer later on somehow due to L3-only policies 🤔 ...I guess that's the origin of how we missed this bug previously.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
AllowsL4()
has value in avoiding creating redirects when they are "clearly" denied (all traffic is denied, or all traffic on the port of the redirect is denies). I guessL4
in the function name may refer to the fact that it is not checking forL3
. In general, it is not possible deduce that a redirect should not be created based on the current contents of the desired map state, as a FQDN policy may only later produce the IDs that are allowed, i.e., at the time ofaddRedirects()
the identity that will actually be allowed to have a redirect may not exist yet, it is not possible to check for that yet-non-existing key value.It might be better to invert the return value and the name of
AllowsL4
toDeniesL4
, returning true if the given L4 is denied for everybody?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.
Did the rename.