From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: <bot+bpf-ci@kernel.org>, <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>,
<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>, <martin.lau@kernel.org>,
<clm@meta.com>, <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next v13 6/8] bpf: Add syscall common attributes support for map_create
Date: Mon, 11 May 2026 10:07:15 -0700 [thread overview]
Message-ID: <DIG0G9IFXF42.3O4K6XV8RGQBG@gmail.com> (raw)
In-Reply-To: <fad54bcc2f9363f61cda44680e7189ad7a510d81dc52f444a4c30a3fcd37df1d@mail.kernel.org>
On Mon May 11, 2026 at 9:19 AM PDT, bot+bpf-ci wrote:
>> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
>> index 8433430dedb7..c15a4c26a43b 100644
>> --- a/include/linux/bpf_verifier.h
>> +++ b/include/linux/bpf_verifier.h
>
> [ ... ]
>
>> diff --git a/kernel/bpf/log.c b/kernel/bpf/log.c
>> index fd12ad5a0338..62fe6ed18374 100644
>> --- a/kernel/bpf/log.c
>> +++ b/kernel/bpf/log.c
>
> [ ... ]
>
>> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
>> index 2fa05ba8f161..54b43e16848a 100644
>> --- a/kernel/bpf/syscall.c
>> +++ b/kernel/bpf/syscall.c
>
> [ ... ]
>
>> @@ -1611,6 +1632,31 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
>> return err;
>> }
>>
>> +static int map_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_common_attr *attr_common,
>> + bpfptr_t uattr_common, u32 size_common)
>> +{
>> + struct bpf_verifier_log *log;
>> + struct bpf_log_attr attr_log;
>> + int err, ret;
>> +
>> + log = bpf_log_attr_create_vlog(&attr_log, attr_common, uattr_common, size_common);
>> + if (IS_ERR(log))
>> + return PTR_ERR(log);
>> +
>> + err = __map_create(attr, uattr, log);
>> +
>> + ret = bpf_log_attr_finalize(&attr_log, log);
>> + if (ret) {
>> + if (err >= 0)
>> + close_fd(err);
>> + err = ret;
>
> When bpf_log_attr_finalize() returns an error (say -ENOSPC for log buffer
> truncation or -EFAULT for copy_to_user failure) after __map_create() already
> returned a negative error (for example -EINVAL from CHECK_ATTR or -EPERM from
> security checks), does it make sense to overwrite the original map creation
> error with the log finalization error?
>
> The result is that userspace receives -ENOSPC or -EFAULT instead of the
> actual reason the map creation failed. A user with an undersized log buffer
> might retry with a larger buffer expecting success, when the real issue is
> that the map creation itself was rejected for a different reason.
>
> Looking at bpf_check() in kernel/bpf/verifier.c (around the verifier log
> finalization), it uses similar logic with 'err = ret;' reassignment. However,
> that doesn't appear to have the preserve-original-error comment that would
> clarify the intended behavior for this scenario.
I guess sinle line comment wouldn't hurt.
>
>> + }
>> +
>> +free:
>
> Does anything use this free: label? The only exit path before it is the early
> return for IS_ERR(log), which correctly returns directly since log is an error
> pointer and doesn't need cleanup. There doesn't seem to be any 'goto free;'
> statement in the function.
>
> With -Wunused-label enabled by default in the kernel build (part of -Wall),
> this will generate a compiler warning. When building with -Werror (common in
> CI configurations and allmodconfig builds), this would break the build.
good point. pls fix.
next prev parent reply other threads:[~2026-05-11 17:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 15:28 [PATCH bpf-next v13 0/8] bpf: Extend BPF syscall with common attributes support Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 1/8] " Leon Hwang
2026-05-11 16:19 ` bot+bpf-ci
2026-05-11 16:53 ` Alexei Starovoitov
2026-05-12 2:41 ` Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 2/8] libbpf: Add support for extended BPF syscall Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 3/8] bpf: Refactor reporting log_true_size for prog_load Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 4/8] bpf: Add syscall common attributes support " Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 5/8] bpf: Add syscall common attributes support for btf_load Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 6/8] bpf: Add syscall common attributes support for map_create Leon Hwang
2026-05-11 16:19 ` bot+bpf-ci
2026-05-11 17:07 ` Alexei Starovoitov [this message]
2026-05-12 2:47 ` Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 7/8] libbpf: " Leon Hwang
2026-05-11 15:28 ` [PATCH bpf-next v13 8/8] selftests/bpf: Add tests to verify map create failure log 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=DIG0G9IFXF42.3O4K6XV8RGQBG@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=a.s.protopopov@gmail.com \
--cc=aalbersh@redhat.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@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