Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

info: error on loading wrong BPF object type #1581

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 9, 2024

  1. info: error on loading wrong BPF object type

    Before this patch, ebpf.LoadPinnedMap and ebpf.LoadPinnedProg both
    succeed when used with the wrong object type. Meaning that you can open
    a prog using epbf.LoadPinnedMap or vice-versa and you'll get garbage
    data in the object's info.
    
    To my knowledge, there are two ways of knowing from an opened FD which
    object type it is:
    * checking for specific fields in /proc/self/fdinfo/<fd>;
    * running readlink(2) on /proc/self/fd/<fd> and check for
      anon_inode:bpf-prog or anon_inode:bpf-map.
    
    This is a breaking change for users relying on LoadPinned<object> to
    open any object: I've been using that behavior to scan BPF filesystem.
    
    Signed-off-by: Mahe Tardy <[email protected]>
    mtardy committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    4a960d5 View commit details
    Browse the repository at this point in the history