Linux userland API discussions
 help / color / mirror / Atom feed
From: bot+bpf-ci@kernel.org
To: leon.hwang@linux.dev,bpf@vger.kernel.org
Cc: ast@kernel.org,daniel@iogearbox.net,john.fastabend@gmail.com,andrii@kernel.org,martin.lau@linux.dev,eddyz87@gmail.com,song@kernel.org,yonghong.song@linux.dev,kpsingh@kernel.org,sdf@fomichev.me,haoluo@google.com,jolsa@kernel.org,shuah@kernel.org,brauner@kernel.org,sforshee@kernel.org,yuichtsu@amazon.com,aalbersh@redhat.com,leon.hwang@linux.dev,willemb@google.com,kerneljasonxing@gmail.com,chen.dylane@linux.dev,yatsenko@meta.com,memxor@gmail.com,a.s.protopopov@gmail.com,ameryhung@gmail.com,rongtao@cestc.cn,linux-kernel@vger.kernel.org,linux-api@vger.kernel.org,linux-kselftest@vger.kernel.org,kernel-patches-bot@fb.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v14 2/8] libbpf: Add support for extended BPF syscall
Date: Tue, 12 May 2026 16:23:15 +0000 (UTC)	[thread overview]
Message-ID: <44819125e8a416353eb3e314e7804d2c762ea87331f98f1396eaa8b86421d950@mail.kernel.org> (raw)
In-Reply-To: <20260512153157.28382-3-leon.hwang@linux.dev>

[-- Attachment #1: Type: text/plain, Size: 1802 bytes --]

> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 5846de364209..9d8740761b7a 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c

[ ... ]

> +int probe_sys_bpf_ext(void)
> +{
> +	const size_t attr_sz = offsetofend(union bpf_attr, prog_token_fd);
> +	union bpf_attr attr;
> +	int fd;
> +
> +	memset(&attr, 0, attr_sz);
> +	fd = syscall(__NR_bpf, BPF_PROG_LOAD | BPF_COMMON_ATTRS, &attr, attr_sz, NULL,
> +		     sizeof(struct bpf_common_attr));
> +	if (fd >= 0) {
> +		close(fd);
> +		return -EINVAL;
                        ^^^^^^

Should probe_sys_bpf_ext() return 1 instead of -EINVAL when fd >= 0?

The probe function detects kernel support for extended BPF syscall
attributes by calling the BPF syscall with the BPF_COMMON_ATTRS flag
and a NULL pointer for common attributes.

The expected outcomes are:
- New kernel with support: errno=EFAULT (can't copy from NULL) -> return 1
- Old kernel without support: errno!=EFAULT (invalid command) -> return 0

If the syscall succeeds (fd >= 0), that definitively proves the kernel
accepts the extended syscall format and supports BPF_COMMON_ATTRS. The
function should return 1 (supported) rather than -EINVAL (error).

Returning -EINVAL causes feat_supported() in features.c to print a
warning "Detection of kernel BPF syscall common attributes support
support failed: Invalid argument" and mark the feature as MISSING,
incorrectly reporting that the kernel doesn't support the feature when
the successful syscall proves it does.

> +	}
> +	return errno == EFAULT ? 1 : 0;
> +}

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/25745661172

  reply	other threads:[~2026-05-12 16:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 15:31 [PATCH bpf-next v14 0/8] bpf: Extend BPF syscall with common attributes support Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 1/8] " Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 2/8] libbpf: Add support for extended BPF syscall Leon Hwang
2026-05-12 16:23   ` bot+bpf-ci [this message]
2026-05-13  2:10     ` Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 3/8] bpf: Refactor reporting log_true_size for prog_load Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 4/8] bpf: Add syscall common attributes support " Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 5/8] bpf: Add syscall common attributes support for btf_load Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 6/8] bpf: Add syscall common attributes support for map_create Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 7/8] libbpf: " Leon Hwang
2026-05-12 15:31 ` [PATCH bpf-next v14 8/8] selftests/bpf: Add tests to verify map create failure log Leon Hwang
2026-05-12 19:50 ` [PATCH bpf-next v14 0/8] bpf: Extend BPF syscall with common attributes support patchwork-bot+netdevbpf

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=44819125e8a416353eb3e314e7804d2c762ea87331f98f1396eaa8b86421d950@mail.kernel.org \
    --to=bot+bpf-ci@kernel.org \
    --cc=a.s.protopopov@gmail.com \
    --cc=aalbersh@redhat.com \
    --cc=ameryhung@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=chen.dylane@linux.dev \
    --cc=clm@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-patches-bot@fb.com \
    --cc=kerneljasonxing@gmail.com \
    --cc=kpsingh@kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=rongtao@cestc.cn \
    --cc=sdf@fomichev.me \
    --cc=sforshee@kernel.org \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=willemb@google.com \
    --cc=yatsenko@meta.com \
    --cc=yonghong.song@linux.dev \
    --cc=yuichtsu@amazon.com \
    /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