mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 18:09:57 +00:00
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).
Fixes: d4baa9368a
("bpf, xdp: Extract common XDP program attachment logic")
Reported-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20200812022923.1217922-1-andriin@fb.com
This commit is contained in:
parent
da7bdfdd23
commit
068d9d1eba
1 changed files with 4 additions and 4 deletions
|
@ -8913,10 +8913,6 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
|
||||||
NL_SET_ERR_MSG(extack, "Active program does not match expected");
|
NL_SET_ERR_MSG(extack, "Active program does not match expected");
|
||||||
return -EEXIST;
|
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 */
|
/* put effective new program into new_prog */
|
||||||
if (link)
|
if (link)
|
||||||
|
@ -8927,6 +8923,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
|
||||||
enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
|
enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
|
||||||
? XDP_MODE_DRV : 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)) {
|
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");
|
NL_SET_ERR_MSG(extack, "Native and generic XDP can't be active at the same time");
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
|
|
Loading…
Reference in a new issue