]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xdp: Reset prog in dev_change_xdp_fd when fd is negative
authorDavid Ahern <dsahern@gmail.com>
Sun, 12 Apr 2020 13:32:04 +0000 (07:32 -0600)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 14 Apr 2020 19:38:02 +0000 (21:38 +0200)
The commit mentioned in the Fixes tag reuses the local prog variable
when looking up an expected_fd. The variable is not reset when fd < 0
causing a detach with the expected_fd set to actually call
dev_xdp_install for the existing program. The end result is that the
detach does not happen.

Fixes: fcdd88151a1f ("xdp: Support specifying expected existing program when attaching XDP")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/20200412133204.43847-1-dsahern@kernel.org
net/core/dev.c

index df8097b8e286938b3d9bcf98c543eb3551cf3563..522288177bbd8ce00d2152c218d7eef6fbcd82ab 100644 (file)
@@ -8667,8 +8667,8 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
        const struct net_device_ops *ops = dev->netdev_ops;
        enum bpf_netdev_command query;
        u32 prog_id, expected_id = 0;
-       struct bpf_prog *prog = NULL;
        bpf_op_t bpf_op, bpf_chk;
+       struct bpf_prog *prog;
        bool offload;
        int err;
 
@@ -8734,6 +8734,7 @@ int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
        } else {
                if (!prog_id)
                        return 0;
+               prog = NULL;
        }
 
        err = dev_xdp_install(dev, bpf_op, extack, flags, prog);