Commit c0c6bde5 authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Alexei Starovoitov

netdevsim: Don't accept device bound programs

Commit 2b3486bc ("bpf: Introduce device-bound XDP programs") introduced
device-bound programs by largely reusing existing offloading infrastructure.
This changed the semantics of 'prog->aux->offload' a bit. Now, it's non-NULL
for both offloaded and device-bound programs.

Instead of looking at 'prog->aux->offload' let's call bpf_prog_is_offloaded
which should be true iff the program is offloaded and not merely device-bound.

Fixes: 2b3486bc ("bpf: Introduce device-bound XDP programs")
Reported-by: syzbot+44c2416196b7c607f226@syzkaller.appspotmail.com
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Cc: Dipendra Khadka <kdipendra88@gmail.com>
Link: https://lore.kernel.org/bpf/20231114045453.1816995-2-sdf@google.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent d3fa86b1
...@@ -93,7 +93,7 @@ static void nsim_prog_set_loaded(struct bpf_prog *prog, bool loaded) ...@@ -93,7 +93,7 @@ static void nsim_prog_set_loaded(struct bpf_prog *prog, bool loaded)
{ {
struct nsim_bpf_bound_prog *state; struct nsim_bpf_bound_prog *state;
if (!prog || !prog->aux->offload) if (!prog || !bpf_prog_is_offloaded(prog->aux))
return; return;
state = prog->aux->offload->dev_priv; state = prog->aux->offload->dev_priv;
...@@ -311,7 +311,7 @@ nsim_setup_prog_hw_checks(struct netdevsim *ns, struct netdev_bpf *bpf) ...@@ -311,7 +311,7 @@ nsim_setup_prog_hw_checks(struct netdevsim *ns, struct netdev_bpf *bpf)
if (!bpf->prog) if (!bpf->prog)
return 0; return 0;
if (!bpf->prog->aux->offload) { if (!bpf_prog_is_offloaded(bpf->prog->aux)) {
NSIM_EA(bpf->extack, "xdpoffload of non-bound program"); NSIM_EA(bpf->extack, "xdpoffload of non-bound program");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment