From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Roberto Sassu <roberto.sassu@huawei.com>
Subject: [PATCH v2 1/3] bpf: make bpf_key an opaque type
Date: Wed, 30 Jul 2025 13:27:43 -0400 [thread overview]
Message-ID: <20250730172745.8480-2-James.Bottomley@HansenPartnership.com> (raw)
In-Reply-To: <20250730172745.8480-1-James.Bottomley@HansenPartnership.com>
Since the only consumers of struct bpf_key are bpf scripts which call
the bpf kfuncs which take struct bpf_key, only the implementing
functions in bpf_trace.c should be reaching inside this structure.
Enforce this by making the structure opaque in the header with a body
that's only defined inside bpf_trace.c
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
include/linux/bpf.h | 5 +----
kernel/trace/bpf_trace.c | 5 +++++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index f9cd2164ed23..34b2df7aaf3e 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -3656,10 +3656,7 @@ static inline void bpf_cgroup_atype_put(int cgroup_atype) {}
struct key;
#ifdef CONFIG_KEYS
-struct bpf_key {
- struct key *key;
- bool has_ref;
-};
+struct bpf_key;
#endif /* CONFIG_KEYS */
static inline bool type_is_alloc(u32 type)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 3ae52978cae6..e7bf00d1cd05 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1242,6 +1242,11 @@ static const struct bpf_func_proto bpf_get_func_arg_cnt_proto = {
};
#ifdef CONFIG_KEYS
+struct bpf_key {
+ struct key *key;
+ bool has_ref;
+};
+
__bpf_kfunc_start_defs();
/**
--
2.43.0
next prev parent reply other threads:[~2025-07-30 17:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 17:27 [PATCH v2 0/3] bpf: tidy up internals of bpf key handling James Bottomley
2025-07-30 17:27 ` James Bottomley [this message]
2025-07-30 17:27 ` [PATCH v2 2/3] bpf: remove bpf_key reference James Bottomley
2025-07-31 17:03 ` Alexei Starovoitov
2025-07-31 17:27 ` James Bottomley
2025-07-31 18:04 ` Alexei Starovoitov
2025-07-31 18:53 ` James Bottomley
2025-07-30 17:27 ` [PATCH v2 3/3] bpf: eliminate the allocation of an intermediate struct bpf_key James Bottomley
2025-07-31 22:28 ` kernel test robot
2025-08-01 1:59 ` kernel test robot
2025-08-04 6:21 ` Dan Carpenter
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=20250730172745.8480-2-James.Bottomley@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=bpf@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=roberto.sassu@huawei.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 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.