Skip to content

Commit 353b190

Browse files
jejbKernel Patches Daemon
authored andcommitted
bpf: make bpf_key an opaque type
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 <[email protected]>
1 parent 9879802 commit 353b190

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

include/linux/bpf.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,10 +3656,7 @@ static inline void bpf_cgroup_atype_put(int cgroup_atype) {}
36563656
struct key;
36573657

36583658
#ifdef CONFIG_KEYS
3659-
struct bpf_key {
3660-
struct key *key;
3661-
bool has_ref;
3662-
};
3659+
struct bpf_key;
36633660
#endif /* CONFIG_KEYS */
36643661

36653662
static inline bool type_is_alloc(u32 type)

kernel/trace/bpf_trace.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,11 @@ static const struct bpf_func_proto bpf_get_func_arg_cnt_proto = {
12421242
};
12431243

12441244
#ifdef CONFIG_KEYS
1245+
struct bpf_key {
1246+
struct key *key;
1247+
bool has_ref;
1248+
};
1249+
12451250
__bpf_kfunc_start_defs();
12461251

12471252
/**

0 commit comments

Comments
 (0)