All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/4] bpf: Improve error reporting for freplace attachment failure
@ 2025-02-17 15:43 Leon Hwang
  2025-02-17 15:43 ` [PATCH bpf-next v3 1/4] bpf, verifier: Add missing newline of bpf_log in bpf_check_attach_target Leon Hwang
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Leon Hwang @ 2025-02-17 15:43 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, yonghong.song, song, eddyz87, me, leon.hwang,
	kernel-patches-bot

This patch series improves error reporting for BPF_LINK_CREATE when
attaching freplace programs. Inspired by the discussion in
"[PATCH bpf-next v2] bpf: Add bpf_check_attach_target_with_klog method to
output failure logs to kernel"[0], this series enhances that freplace
attachment failure returns meaningful logs to userspace, aiding debugging.

For example, when attempting to attach a freplace program to a static
function:

libbpf: prog 'new_test_pkt_access': failed to attach to freplace: -EINVAL
libbpf: prog 'new_test_pkt_access': attach log: subprog_tail() is not a global function

Patch breakdown:
1. bpf, verifier: Add missing newline of bpf_log in bpf_check_attach_target
    * Add the missing newline in
      bpf_log(log, "Target program bound device mismatch").
2. bpf: Report log of freplace attach failure
    * Extends BPF_LINK_CREATE to report detailed error logs.
3. bpf, libbpf: Capture log of freplace attach failure
    * Modifies libbpf to capture and print attachment logs.
4. selftests/bpf: Add a test case for freplace attachment failure logging
    * Introduces a selftest to validate error reporting.

Links:
[0] https://lore.kernel.org/bpf/CAEf4BzbbyojuFSS7xQ3+jZb=dHzOaZfMbtT+WnypW2LPwOUwRw@mail.gmail.com/

Changes:
v2: https://lore.kernel.org/bpf/20240725051511.57112-1-me@manjusaka.me/
v2 -> v3:
  * Address comment from Andrii:
    * Report back the reason for declining freplace attachment instead of
      logging in dmesg.

Leon Hwang (4):
  bpf, verifier: Add missing newline of bpf_log in
    bpf_check_attach_target
  bpf: Improve error reporting for freplace attachment failure
  bpf, libbpf: Capture and log freplace attachment failure
  selftests/bpf: Add test case for freplace attachment failure logging

 include/uapi/linux/bpf.h                      |  2 +
 kernel/bpf/syscall.c                          | 51 ++++++++++++++++---
 kernel/bpf/verifier.c                         |  2 +-
 tools/include/uapi/linux/bpf.h                |  2 +
 tools/lib/bpf/bpf.c                           |  6 ++-
 tools/lib/bpf/bpf.h                           |  2 +
 tools/lib/bpf/libbpf.c                        | 14 ++++-
 .../bpf/prog_tests/tracing_link_attach_log.c  | 42 +++++++++++++++
 8 files changed, 109 insertions(+), 12 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_link_attach_log.c

-- 
2.47.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-18  3:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-17 15:43 [PATCH bpf-next v3 0/4] bpf: Improve error reporting for freplace attachment failure Leon Hwang
2025-02-17 15:43 ` [PATCH bpf-next v3 1/4] bpf, verifier: Add missing newline of bpf_log in bpf_check_attach_target Leon Hwang
2025-02-17 15:43 ` [PATCH bpf-next v3 2/4] bpf: Improve error reporting for freplace attachment failure Leon Hwang
2025-02-18  3:01   ` Alexei Starovoitov
2025-02-18  3:29     ` Leon Hwang
2025-02-17 15:43 ` [PATCH bpf-next v3 3/4] bpf, libbpf: Capture and log " Leon Hwang
2025-02-17 15:43 ` [PATCH bpf-next v3 4/4] selftests/bpf: Add test case for freplace attachment failure logging Leon Hwang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.