bpf: prevent offloaded programs from running on host via tcx/netkit - #8673
Open
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
Open
bpf: prevent offloaded programs from running on host via tcx/netkit#8673kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
kernel-patches-daemon-bpf-rc[bot] wants to merge 3 commits into
Conversation
An offloaded program runs on the NIC, so its bpf_func is set to bpf_prog_warn_on_exec(). tcx and netkit run programs on the host with bpf_prog_run(), so attaching an offloaded program to them hits the WARN on the first packet. Both tcx and netkit go through bpf_mprog_attach(), so add the check there once instead of in every attach path. Only check SCHED_CLS programs, so a future mprog user that wants offloaded programs still works. Fixes: 053c8e1 ("bpf: Add generic attach/detach/query API for multi-progs") Reported-by: Yinhao Hu <dddddd@hust.edu.cn> Reported-by: Kaiyan Mei <M202472210@hust.edu.cn> Reported-by: Dongliang Mu <dzm91@hust.edu.cn> Closes: https://lore.kernel.org/bpf/64d8e2b5-a214-4f3c-b9e8-bcedbcb2c602@hust.edu.cn/ Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
bpf_xdp_link_update() calls dev_xdp_install() directly and skips dev_xdp_attach(), so the checks in dev_xdp_attach() do not run. A user can make an XDP link with a normal program and then swap in an offloaded or device-bound program with BPF_LINK_UPDATE, which puts it on the software path. Move the three program checks (offloaded, bound to another device, and device-bound in generic mode) from dev_xdp_attach() into dev_xdp_install(), so both the attach path and the link update path are covered. Fixes: 026a4c2 ("bpf, xdp: Implement LINK_UPDATE for BPF XDP link") Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
bpf_xdp_link_update() used to skip the checks in dev_xdp_attach(). Add a test that makes a generic XDP link with a normal program and then tries to swap in a device-bound program, which must fail. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Author
|
Upstream branch: d114bb9 |
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.
Pull request for series with
subject: bpf: prevent offloaded programs from running on host via tcx/netkit
version: 4
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1143071