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: Resolve fext program type when checking map compatibility #4207

Closed
wants to merge 3 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: bpf: Resolve fext program type when checking map compatibility
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=704318

@kernel-patches-bot
Copy link
Author

Upstream branch: 01de112
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704318
version: 3

@kernel-patches-bot
Copy link
Author

Upstream branch: 01de112
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704318
version: 3

@kernel-patches-bot
Copy link
Author

Upstream branch: 01de112
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704318
version: 3

@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=704318 expired. Closing PR.

@kernel-patches-bot
Copy link
Author

Upstream branch: 01de112
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704344
version: 4

@kernel-patches-bot
Copy link
Author

Upstream branch: 7ae9888
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704344
version: 4

@kernel-patches-bot
Copy link
Author

Upstream branch: e89f3ed
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704344
version: 4

@kernel-patches-bot
Copy link
Author

Upstream branch: 4121d44
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704344
version: 4

The bpf_prog_map_compatible() check makes sure that BPF program types are
not mixed inside BPF map types that can contain programs (tail call maps,
cpumaps and devmaps). It does this by setting the fields of the map->owner
struct to the values of the first program being checked against, and
rejecting any subsequent programs if the values don't match.

One of the values being set in the map owner struct is the program type,
and since the code did not resolve the prog type for fext programs, the map
owner type would be set to PROG_TYPE_EXT and subsequent loading of programs
of the target type into the map would fail.

This bug is seen in particular for XDP programs that are loaded as
PROG_TYPE_EXT using libxdp; these cannot insert programs into devmaps and
cpumaps because the check fails as described above.

Fix the bug by resolving the fext program type to its target program type
as elsewhere in the verifier. This requires constifying the parameter of
resolve_prog_type() to avoid a compiler warning from the new call site.

v3:
- Add Yonghong's ACK

Fixes: f45d5b6 ("bpf: generalise tail call map compatibility check")
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
@kernel-patches-bot
Copy link
Author

Upstream branch: 4121d44
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=704610
version: 5

…program

This adds a simple test for inserting an XDP program into a cpumap that is
"owned" by an XDP program that was loaded as PROG_TYPE_EXT (as libxdp
does). Prior to the kernel fix this would fail because the map type
ownership would be set to PROG_TYPE_EXT instead of being resolved to
PROG_TYPE_XDP.

v5:
- Fix a few nits from Andrii, add his ACK
v4:
- Use skeletons for selftest
v3:
- Update comment to better explain the cause
- Add Yonghong's ACK

Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=704610 irrelevant now. Closing PR.

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