public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	Leon Hwang <leon.hwang@linux.dev>
Subject: [RFC PATCH bpf-next v3 00/10] bpf: Extend bpf syscall with common attributes support
Date: Thu,  2 Oct 2025 23:48:31 +0800	[thread overview]
Message-ID: <20251002154841.99348-1-leon.hwang@linux.dev> (raw)

This proposal builds upon the discussion in
"[PATCH bpf-next v4 0/4] bpf: Improve error reporting for freplace attachment failure"[1].

This patch set introduces support for *common attributes* in the 'bpf()'
syscall, providing a unified mechanism for passing shared metadata across
all BPF commands.

The initial set of common attributes includes:

1. 'log_buf': User-provided buffer for storing log output.
2. 'log_size': Size of the provided log buffer.
3. 'log_level': Verbosity level for logging.
4. 'log_true_size': The size of log reported by kernel.

With this extension, the 'bpf()' syscall will be able to return meaningful
error messages (e.g., failures of creating map), improving debuggability
and user experience.

Changes:
RFC v2 -> RFC v3:
* Rename probe_sys_bpf_extended to probe_sys_bpf_ext.
* Refactor reporting 'log_true_size' for prog_load.
* Refactor reporting 'btf_log_true_size' for btf_load.
* Add warnings for internal bugs in map_create.
* Check log_true_size in test cases.
* Address comment from Alexei:
  * Change kvzalloc/kvfree to kzalloc/kfree.
* Address comments from Andrii:
  * Move BPF_COMMON_ATTRS to 'enum bpf_cmd' alongside brief comment.
  * Add bpf_check_uarg_tail_zero() for extra checks.
  * Rename sys_bpf_extended to sys_bpf_ext.
  * Rename sys_bpf_fd_extended to sys_bpf_ext_fd.
  * Probe the new feature using NULL and -EFAULT.
  * Move probe_sys_bpf_ext to libbpf_internal.h and drop LIBBPF_API.
  * Return -EUERS when log attrs are conflict between bpf_attr and
    bpf_common_attr.
  * Avoid touching bpf_vlog_init().
  * Update the reason messages in map_create.
  * Finalize the log using __cleanup().
  * Report log size to users.
  * Change type of log_buf from '__u64' to 'const char *' and cast type
    using ptr_to_u64() in bpf_map_create().
  * Do not return -EOPNOTSUPP when kernel doesn't support this feature
    in bpf_map_create().
  * Add log_level support for map creation for consistency.
* Address comment from Eduard:
  * Use common_attrs->log_level instead of BPF_LOG_FIXED.

RFC v1 -> RFC v2:
* Fix build error reported by test bot.
* Address comments from Alexei:
  * Drop new uapi for freplace.
  * Add common attributes support for prog_load and btf_load.
  * Add common attributes support for map_create.

Links:
[1] https://lore.kernel.org/bpf/20250224153352.64689-1-leon.hwang@linux.dev/

Leon Hwang (10):
  bpf: Extend bpf syscall with common attributes support
  libbpf: Add support for extended bpf syscall
  bpf: Refactor reporting log_true_size for prog_load
  bpf: Add common attr support for prog_load
  bpf: Refactor reporting btf_log_true_size for btf_load
  bpf: Add common attr support for btf_load
  bpf: Add warnings for internal bugs in map_create
  bpf: Add common attr support for map_create
  libbpf: Add common attr support for map_create
  selftests/bpf: Add cases to test map create failure log

 include/linux/bpf.h                           |   2 +-
 include/linux/btf.h                           |   2 +-
 include/linux/syscalls.h                      |   3 +-
 include/uapi/linux/bpf.h                      |   8 +
 kernel/bpf/btf.c                              |  25 +-
 kernel/bpf/syscall.c                          | 250 ++++++++++++++++--
 kernel/bpf/verifier.c                         |  12 +-
 tools/include/uapi/linux/bpf.h                |   8 +
 tools/lib/bpf/bpf.c                           |  50 +++-
 tools/lib/bpf/bpf.h                           |   9 +-
 tools/lib/bpf/features.c                      |   8 +
 tools/lib/bpf/libbpf_internal.h               |   3 +
 .../selftests/bpf/prog_tests/map_init.c       | 140 ++++++++++
 13 files changed, 461 insertions(+), 59 deletions(-)

--
2.51.0


             reply	other threads:[~2025-10-02 15:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-02 15:48 Leon Hwang [this message]
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 01/10] bpf: Extend bpf syscall with common attributes support Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 02/10] libbpf: Add support for extended bpf syscall Leon Hwang
2025-10-06 23:08   ` Andrii Nakryiko
2025-10-09  5:15     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 03/10] bpf: Refactor reporting log_true_size for prog_load Leon Hwang
2025-10-02 18:34   ` Alexei Starovoitov
2025-10-03  2:06     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 04/10] bpf: Add common attr support " Leon Hwang
2025-10-02 23:51   ` Alexei Starovoitov
2025-10-03  2:25     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 05/10] bpf: Refactor reporting btf_log_true_size for btf_load Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 06/10] bpf: Add common attr support " Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 07/10] bpf: Add warnings for internal bugs in map_create Leon Hwang
2025-10-03  0:06   ` Alexei Starovoitov
2025-10-03  2:31     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 08/10] bpf: Add common attr support for map_create Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 09/10] libbpf: " Leon Hwang
2025-10-06 23:08   ` Andrii Nakryiko
2025-10-09  5:35     ` Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 10/10] selftests/bpf: Add cases to test map create failure log Leon Hwang
2025-10-03  6:38 ` [syzbot ci] Re: bpf: Extend bpf syscall with common attributes support syzbot ci
2025-10-03  6:44   ` Leon Hwang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251002154841.99348-1-leon.hwang@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox