Merged
Conversation
This has been an ambiguous flag since its inception. Internally, we would allow maps to be created with BPF_F_RDONLY_PROG, but not freeze them afterwards. Conversely, we would allow MapSpecs with Freeze set to 'true', but without the rdonly map flag set. The latter case has caused subtle bugs in the past, since BPF_MAP_FREEZE only blocks further modifications from user space, but doesn't actually mark the map as readonly for the verifier. This will prevent code pruning and other optimizations from taking place. This commit removes the Freeze field in favor of the map flag and adds a helper to keep existing call sites simple. Sourcegraph code search yields no references to this field in open-source code. Signed-off-by: Timo Beckers <[email protected]>
lmb
reviewed
Sep 13, 2024
ti-mo
added a commit
to ti-mo/ebpf
that referenced
this pull request
Sep 24, 2024
In cilium#1558, it was pointed out that BPF_F_RDONLY_PROG only implies a map being read-only from bpf space, not user space. Using the flag to trigger freezing a map from user space doesn't make much sense. Change this to a name-based trigger, more closely resembling the libbpf behaviour. Signed-off-by: Timo Beckers <[email protected]>
ti-mo
added a commit
that referenced
this pull request
Sep 24, 2024
In #1558, it was pointed out that BPF_F_RDONLY_PROG only implies a map being read-only from bpf space, not user space. Using the flag to trigger freezing a map from user space doesn't make much sense. Change this to a name-based trigger, more closely resembling the libbpf behaviour. Signed-off-by: Timo Beckers <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This has been an ambiguous flag since its inception. Internally, we would allow maps to be created with BPF_F_RDONLY_PROG, but not freeze them afterwards. Conversely, we would allow MapSpecs with Freeze set to 'true', but without the rdonly map flag set.
The latter case has caused subtle bugs in the past, since BPF_MAP_FREEZE only blocks further modifications from user space, but doesn't actually mark the map as readonly for the verifier. This will prevent code pruning and other optimizations from taking place.
This commit removes the Freeze field in favor of the map flag and adds a helper to keep existing call sites simple. Sourcegraph code search yields no references to this field in open-source code.