Skip to content
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

map: remove MapSpec.Freeze field #1558

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Conversation

ti-mo
Copy link
Collaborator

@ti-mo ti-mo commented Sep 3, 2024

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.

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]>
@ti-mo ti-mo requested a review from a team as a code owner September 3, 2024 15:04
@github-actions github-actions bot added the breaking-change Changes exported API label Sep 3, 2024
@ti-mo ti-mo merged commit 15d4f24 into cilium:main Sep 3, 2024
17 checks passed
@ti-mo ti-mo deleted the tb/remove-mapspec-freeze branch September 3, 2024 15:32
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Changes exported API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants