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 07/10] bpf: Add warnings for internal bugs in map_create
Date: Thu, 2 Oct 2025 23:48:38 +0800 [thread overview]
Message-ID: <20251002154841.99348-8-leon.hwang@linux.dev> (raw)
In-Reply-To: <20251002154841.99348-1-leon.hwang@linux.dev>
In next commit, it will report users the reason of -EINVAL in
map_create.
However, as for the check of '!ops' and '!ops->map_mem_usage', it
shouldn't report the reason as they would be internal bugs.
Instead, add WARN_ON_ONCE to them. Then, it is able to check dmesg to get
the error details.
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
---
kernel/bpf/syscall.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index fc1b5c8c5e82f..49db250a2f5da 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -1406,7 +1406,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
return -EINVAL;
map_type = array_index_nospec(map_type, ARRAY_SIZE(bpf_map_types));
ops = bpf_map_types[map_type];
- if (!ops)
+ if (WARN_ON_ONCE(!ops))
return -EINVAL;
if (ops->map_alloc_check) {
@@ -1416,7 +1416,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr)
}
if (attr->map_ifindex)
ops = &bpf_map_offload_ops;
- if (!ops->map_mem_usage)
+ if (WARN_ON_ONCE(!ops->map_mem_usage))
return -EINVAL;
if (token_flag) {
--
2.51.0
next prev parent 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 [RFC PATCH bpf-next v3 00/10] bpf: Extend bpf syscall with common attributes support Leon Hwang
2025-10-02 15:48 ` [RFC PATCH bpf-next v3 01/10] " 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 ` Leon Hwang [this message]
2025-10-03 0:06 ` [RFC PATCH bpf-next v3 07/10] bpf: Add warnings for internal bugs in map_create 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-8-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