mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 15:39:42 -04:00
bpf: Rename __kptr_ref -> __kptr and __kptr -> __kptr_untrusted.
__kptr meant to store PTR_UNTRUSTED kernel pointers inside bpf maps. The concept felt useful, but didn't get much traction, since bpf_rdonly_cast() was added soon after and bpf programs received a simpler way to access PTR_UNTRUSTED kernel pointers without going through restrictive __kptr usage. Rename __kptr_ref -> __kptr and __kptr -> __kptr_untrusted to indicate its intended usage. The main goal of __kptr_untrusted was to read/write such pointers directly while bpf_kptr_xchg was a mechanism to access refcnted kernel pointers. The next patch will allow RCU protected __kptr access with direct read. At that point __kptr_untrusted will be deprecated. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: David Vernet <void@manifault.com> Link: https://lore.kernel.org/bpf/20230303041446.3630-2-alexei.starovoitov@gmail.com
This commit is contained in:
committed by
Daniel Borkmann
parent
944459e88b
commit
03b77e17ae
@@ -4,7 +4,7 @@
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
struct map_value {
|
||||
struct prog_test_ref_kfunc __kptr_ref *ptr;
|
||||
struct prog_test_ref_kfunc __kptr *ptr;
|
||||
};
|
||||
|
||||
struct {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <bpf/bpf_tracing.h>
|
||||
|
||||
struct __cgrps_kfunc_map_value {
|
||||
struct cgroup __kptr_ref * cgrp;
|
||||
struct cgroup __kptr * cgrp;
|
||||
};
|
||||
|
||||
struct hash_map {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
int err;
|
||||
|
||||
struct __cpumask_map_value {
|
||||
struct bpf_cpumask __kptr_ref * cpumask;
|
||||
struct bpf_cpumask __kptr * cpumask;
|
||||
};
|
||||
|
||||
struct array_map {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <bpf/bpf_tracing.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
static struct prog_test_ref_kfunc __kptr_ref *v;
|
||||
static struct prog_test_ref_kfunc __kptr *v;
|
||||
long total_sum = -1;
|
||||
|
||||
extern struct prog_test_ref_kfunc *bpf_kfunc_call_test_acquire(unsigned long *sp) __ksym;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
struct map_value {
|
||||
struct task_struct __kptr *ptr;
|
||||
struct task_struct __kptr_untrusted *ptr;
|
||||
};
|
||||
|
||||
struct {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
struct map_value {
|
||||
struct prog_test_ref_kfunc __kptr *unref_ptr;
|
||||
struct prog_test_ref_kfunc __kptr_ref *ref_ptr;
|
||||
struct prog_test_ref_kfunc __kptr_untrusted *unref_ptr;
|
||||
struct prog_test_ref_kfunc __kptr *ref_ptr;
|
||||
};
|
||||
|
||||
struct array_map {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
struct map_value {
|
||||
char buf[8];
|
||||
struct prog_test_ref_kfunc __kptr *unref_ptr;
|
||||
struct prog_test_ref_kfunc __kptr_ref *ref_ptr;
|
||||
struct prog_test_member __kptr_ref *ref_memb_ptr;
|
||||
struct prog_test_ref_kfunc __kptr_untrusted *unref_ptr;
|
||||
struct prog_test_ref_kfunc __kptr *ref_ptr;
|
||||
struct prog_test_member __kptr *ref_memb_ptr;
|
||||
};
|
||||
|
||||
struct array_map {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <bpf/bpf_tracing.h>
|
||||
|
||||
struct __tasks_kfunc_map_value {
|
||||
struct task_struct __kptr_ref * task;
|
||||
struct task_struct __kptr * task;
|
||||
};
|
||||
|
||||
struct hash_map {
|
||||
|
||||
@@ -699,13 +699,13 @@ static int create_cgroup_storage(bool percpu)
|
||||
* struct bpf_timer t;
|
||||
* };
|
||||
* struct btf_ptr {
|
||||
* struct prog_test_ref_kfunc __kptr_untrusted *ptr;
|
||||
* struct prog_test_ref_kfunc __kptr *ptr;
|
||||
* struct prog_test_ref_kfunc __kptr_ref *ptr;
|
||||
* struct prog_test_member __kptr_ref *ptr;
|
||||
* struct prog_test_member __kptr *ptr;
|
||||
* }
|
||||
*/
|
||||
static const char btf_str_sec[] = "\0bpf_spin_lock\0val\0cnt\0l\0bpf_timer\0timer\0t"
|
||||
"\0btf_ptr\0prog_test_ref_kfunc\0ptr\0kptr\0kptr_ref"
|
||||
"\0btf_ptr\0prog_test_ref_kfunc\0ptr\0kptr\0kptr_untrusted"
|
||||
"\0prog_test_member";
|
||||
static __u32 btf_raw_types[] = {
|
||||
/* int */
|
||||
@@ -724,20 +724,20 @@ static __u32 btf_raw_types[] = {
|
||||
BTF_MEMBER_ENC(41, 4, 0), /* struct bpf_timer t; */
|
||||
/* struct prog_test_ref_kfunc */ /* [6] */
|
||||
BTF_STRUCT_ENC(51, 0, 0),
|
||||
BTF_STRUCT_ENC(89, 0, 0), /* [7] */
|
||||
BTF_STRUCT_ENC(95, 0, 0), /* [7] */
|
||||
/* type tag "kptr_untrusted" */
|
||||
BTF_TYPE_TAG_ENC(80, 6), /* [8] */
|
||||
/* type tag "kptr" */
|
||||
BTF_TYPE_TAG_ENC(75, 6), /* [8] */
|
||||
/* type tag "kptr_ref" */
|
||||
BTF_TYPE_TAG_ENC(80, 6), /* [9] */
|
||||
BTF_TYPE_TAG_ENC(80, 7), /* [10] */
|
||||
BTF_TYPE_TAG_ENC(75, 6), /* [9] */
|
||||
BTF_TYPE_TAG_ENC(75, 7), /* [10] */
|
||||
BTF_PTR_ENC(8), /* [11] */
|
||||
BTF_PTR_ENC(9), /* [12] */
|
||||
BTF_PTR_ENC(10), /* [13] */
|
||||
/* struct btf_ptr */ /* [14] */
|
||||
BTF_STRUCT_ENC(43, 3, 24),
|
||||
BTF_MEMBER_ENC(71, 11, 0), /* struct prog_test_ref_kfunc __kptr *ptr; */
|
||||
BTF_MEMBER_ENC(71, 12, 64), /* struct prog_test_ref_kfunc __kptr_ref *ptr; */
|
||||
BTF_MEMBER_ENC(71, 13, 128), /* struct prog_test_member __kptr_ref *ptr; */
|
||||
BTF_MEMBER_ENC(71, 11, 0), /* struct prog_test_ref_kfunc __kptr_untrusted *ptr; */
|
||||
BTF_MEMBER_ENC(71, 12, 64), /* struct prog_test_ref_kfunc __kptr *ptr; */
|
||||
BTF_MEMBER_ENC(71, 13, 128), /* struct prog_test_member __kptr *ptr; */
|
||||
};
|
||||
|
||||
static char bpf_vlog[UINT_MAX >> 8];
|
||||
|
||||
Reference in New Issue
Block a user