Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xdp: Reset prog in dev_change_xdp_fd when fd is negative

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: 92234c8f15c8 ("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

authored by

David Ahern and committed by
Daniel Borkmann
dfa74909 96b2eb6e

+2 -1
+2 -1
net/core/dev.c
··· 8667 8667 const struct net_device_ops *ops = dev->netdev_ops; 8668 8668 enum bpf_netdev_command query; 8669 8669 u32 prog_id, expected_id = 0; 8670 - struct bpf_prog *prog = NULL; 8671 8670 bpf_op_t bpf_op, bpf_chk; 8671 + struct bpf_prog *prog; 8672 8672 bool offload; 8673 8673 int err; 8674 8674 ··· 8734 8734 } else { 8735 8735 if (!prog_id) 8736 8736 return 0; 8737 + prog = NULL; 8737 8738 } 8738 8739 8739 8740 err = dev_xdp_install(dev, bpf_op, extack, flags, prog);