• Toke Høiland-Jørgensen's avatar
    xdp: Remove the xdp_attachment_flags_ok() callback · 998f1729
    Toke Høiland-Jørgensen authored
    Since commit 7f0a8382 ("bpf, xdp: Maintain info on attached XDP BPF
    programs in net_device"), the XDP program attachment info is now maintained
    in the core code. This interacts badly with the xdp_attachment_flags_ok()
    check that prevents unloading an XDP program with different load flags than
    it was loaded with. In practice, two kinds of failures are seen:
    
    - An XDP program loaded without specifying a mode (and which then ends up
      in driver mode) cannot be unloaded if the program mode is specified on
      unload.
    
    - The dev_xdp_uninstall() hook always calls the driver callback with the
      mode set to the type of the program but an empty flags argument, which
      means the flags_ok() check prevents the program from being removed,
      leading to bpf prog reference leaks.
    
    The original reason this check was added was to avoid ambiguity when
    multiple programs were loaded. With the way the checks are done in the core
    now, this is quite simple to enforce in the core code, so let's add a check
    there and get rid of the xdp_attachment_flags_ok() callback entirely.
    
    Fixes: 7f0a8382 ("bpf, xdp: Maintain info on attached XDP BPF programs in net_device")
    Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/bpf/160752225751.110217.10267659521308669050.stgit@toke.dk
    998f1729
xdp.h 7.09 KB