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

bpf: Some fixes for nullness elision #4937

Open
wants to merge 3 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf-rc[bot]
Copy link

Pull request for series with
subject: bpf: Some fixes for nullness elision
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=929753

Previously, we were trying to extract constant map keys for all
bpf_map_lookup_elem(), regardless of map type. This is an issue if the
map has a u64 key and the value is very high, as it can be interpreted
as a negative signed value. This in turn is treated as an error value by
check_func_arg() which causes a valid program to be incorrectly
rejected.

Fix by only extracting constant map keys for relevant maps. See next
commit for an example via selftest.

Reported-by: Marc Hartmayer <[email protected]>
Reported-by: Ilya Leoshkevich <[email protected]>
Tested-by: Marc Hartmayer <[email protected]>
Signed-off-by: Daniel Xu <[email protected]>
Test that very high constant map keys are not interpreted as an error
value by the verifier. This would previously fail.

Signed-off-by: Daniel Xu <[email protected]>
Refactor get_constant_map_key() to disambiguate the constant key
value from potential error values. In the case that the key is
negative, it could be confused for an error.

It's not currently an issue, as the verifier seems to track s32 spills
as u32. So even if the program wrongly uses a negative value for an
arraymap key, the verifier just thinks it's an impossibly high value
which gets correctly discarded.

Refactor anyways to make things cleaner and prevent potential future
issues.

Signed-off-by: Daniel Xu <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5b67071
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=929753
version: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant