bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
Subsystems (3)
PATCH 1/1 bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST
Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be attached is non-NULL (i.e., we are not detaching a BPF program).
Reported-by Stanislav Fomichev <[email protected]>
Fixes d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")
Signed-off-by Andrii Nakryiko <[email protected]>
--- net/core/dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/core/dev.c +4 -4
@@ -8913,10 +8913,6 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extackNL_SET_ERR_MSG (extack,"Active program does not match expected" );return -EEXIST ; } -if ((flags &XDP_FLAGS_UPDATE_IF_NOEXIST ) && cur_prog) { -NL_SET_ERR_MSG (extack,"XDP program already attached" ); -return -EBUSY ; - }/* put effective new program into new_prog */ if (link)
@@ -8927,6 +8923,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extackenum bpf_xdp_mode other_mode = mode ==XDP_MODE_SKB ?XDP_MODE_DRV :XDP_MODE_SKB ; +if ((flags &XDP_FLAGS_UPDATE_IF_NOEXIST ) && cur_prog) { +NL_SET_ERR_MSG (extack,"XDP program already attached" ); +return -EBUSY ; + }if (!offload &&dev_xdp_prog (dev, other_mode)) {NL_SET_ERR_MSG (extack,"Native and generic XDP can't be active at the same time" );return -EEXIST ;
Signature · 1 line
2.24.1
Quoted 6 lines · Andrii Nakryiko
Enforce
XDP_FLAGS_UPDATE_IF_NOEXISTonly if new BPF program to be attached is non-NULL (i.e., we are not detaching a BPF program).Reported-by Stanislav Fomichev <[email protected]>Fixes d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")Signed-off-by Andrii Nakryiko <[email protected]>
Stanislav Fomichev
Tested-byQuoted 11 lines · Toke Høiland-Jørgensen
Quoted 6 lines · Andrii Nakryiko
Enforce
XDP_FLAGS_UPDATE_IF_NOEXISTonly if new BPF program to be attached is non-NULL (i.e., we are not detaching a BPF program).Reported-by Stanislav Fomichev <[email protected]>Fixes d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")Signed-off-by Andrii Nakryiko <[email protected]>
That fixed it for me, thank you!
Tested-by Stanislav Fomichev <[email protected]>
Alexei Starovoitov
AppliedQuoted 8 lines · Stanislav Fomichev
Quoted 6 lines · Toke Høiland-Jørgensen
Quoted 3 lines · Andrii Nakryiko
Enforce
XDP_FLAGS_UPDATE_IF_NOEXISTonly if new BPF program to be attached is non-NULL (i.e., we are not detaching a BPF program).
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Reported-by Stanislav Fomichev <[email protected]>Fixes d4baa9368a5e ("bpf, xdp: Extract common XDP program attachment logic")Signed-off-by Andrii Nakryiko <[email protected]>That fixed it for me, thank you!
Tested-by Stanislav Fomichev <[email protected]>
Applied. Thanks