• Yonghong Song's avatar
    samples/bpf: add error checking for perf ioctl calls in bpf loader · 0ec9552b
    Yonghong Song authored
    load_bpf_file() should fail if ioctl with command
    PERF_EVENT_IOC_ENABLE and PERF_EVENT_IOC_SET_BPF fails.
    When they do fail, proper error messages are printed.
    
    With this change, the below "syscall_tp" run shows that
    the maximum number of bpf progs attaching to the same
    perf tracepoint is indeed enforced.
      $ ./syscall_tp -i 64
      prog #0: map ids 4 5
      ...
      prog #63: map ids 382 383
      $ ./syscall_tp -i 65
      prog #0: map ids 4 5
      ...
      prog #64: map ids 388 389
      ioctl PERF_EVENT_IOC_SET_BPF failed err Argument list too long
    Signed-off-by: default avatarYonghong Song <yhs@fb.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    0ec9552b
bpf_load.c 18.8 KB