diff options
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r-- | include/linux/bpf.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index f57d7fed9ec3..de464e6683b6 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <uapi/linux/bpf.h> | 10 | #include <uapi/linux/bpf.h> |
11 | #include <linux/workqueue.h> | 11 | #include <linux/workqueue.h> |
12 | #include <linux/file.h> | 12 | #include <linux/file.h> |
13 | #include <linux/perf_event.h> | ||
14 | 13 | ||
15 | struct bpf_map; | 14 | struct bpf_map; |
16 | 15 | ||
@@ -37,6 +36,8 @@ struct bpf_map { | |||
37 | u32 key_size; | 36 | u32 key_size; |
38 | u32 value_size; | 37 | u32 value_size; |
39 | u32 max_entries; | 38 | u32 max_entries; |
39 | u32 pages; | ||
40 | struct user_struct *user; | ||
40 | const struct bpf_map_ops *ops; | 41 | const struct bpf_map_ops *ops; |
41 | struct work_struct work; | 42 | struct work_struct work; |
42 | }; | 43 | }; |
@@ -101,6 +102,8 @@ enum bpf_access_type { | |||
101 | BPF_WRITE = 2 | 102 | BPF_WRITE = 2 |
102 | }; | 103 | }; |
103 | 104 | ||
105 | struct bpf_prog; | ||
106 | |||
104 | struct bpf_verifier_ops { | 107 | struct bpf_verifier_ops { |
105 | /* return eBPF function prototype for verification */ | 108 | /* return eBPF function prototype for verification */ |
106 | const struct bpf_func_proto *(*get_func_proto)(enum bpf_func_id func_id); | 109 | const struct bpf_func_proto *(*get_func_proto)(enum bpf_func_id func_id); |
@@ -112,7 +115,7 @@ struct bpf_verifier_ops { | |||
112 | 115 | ||
113 | u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg, | 116 | u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg, |
114 | int src_reg, int ctx_off, | 117 | int src_reg, int ctx_off, |
115 | struct bpf_insn *insn); | 118 | struct bpf_insn *insn, struct bpf_prog *prog); |
116 | }; | 119 | }; |
117 | 120 | ||
118 | struct bpf_prog_type_list { | 121 | struct bpf_prog_type_list { |
@@ -121,14 +124,13 @@ struct bpf_prog_type_list { | |||
121 | enum bpf_prog_type type; | 124 | enum bpf_prog_type type; |
122 | }; | 125 | }; |
123 | 126 | ||
124 | struct bpf_prog; | ||
125 | |||
126 | struct bpf_prog_aux { | 127 | struct bpf_prog_aux { |
127 | atomic_t refcnt; | 128 | atomic_t refcnt; |
128 | u32 used_map_cnt; | 129 | u32 used_map_cnt; |
129 | const struct bpf_verifier_ops *ops; | 130 | const struct bpf_verifier_ops *ops; |
130 | struct bpf_map **used_maps; | 131 | struct bpf_map **used_maps; |
131 | struct bpf_prog *prog; | 132 | struct bpf_prog *prog; |
133 | struct user_struct *user; | ||
132 | union { | 134 | union { |
133 | struct work_struct work; | 135 | struct work_struct work; |
134 | struct rcu_head rcu; | 136 | struct rcu_head rcu; |
@@ -165,9 +167,18 @@ struct bpf_prog *bpf_prog_get(u32 ufd); | |||
165 | void bpf_prog_put(struct bpf_prog *prog); | 167 | void bpf_prog_put(struct bpf_prog *prog); |
166 | void bpf_prog_put_rcu(struct bpf_prog *prog); | 168 | void bpf_prog_put_rcu(struct bpf_prog *prog); |
167 | 169 | ||
168 | struct bpf_map *bpf_map_get(struct fd f); | 170 | struct bpf_map *bpf_map_get(u32 ufd); |
171 | struct bpf_map *__bpf_map_get(struct fd f); | ||
169 | void bpf_map_put(struct bpf_map *map); | 172 | void bpf_map_put(struct bpf_map *map); |
170 | 173 | ||
174 | extern int sysctl_unprivileged_bpf_disabled; | ||
175 | |||
176 | int bpf_map_new_fd(struct bpf_map *map); | ||
177 | int bpf_prog_new_fd(struct bpf_prog *prog); | ||
178 | |||
179 | int bpf_obj_pin_user(u32 ufd, const char __user *pathname); | ||
180 | int bpf_obj_get_user(const char __user *pathname); | ||
181 | |||
171 | /* verify correctness of eBPF program */ | 182 | /* verify correctness of eBPF program */ |
172 | int bpf_check(struct bpf_prog **fp, union bpf_attr *attr); | 183 | int bpf_check(struct bpf_prog **fp, union bpf_attr *attr); |
173 | #else | 184 | #else |
@@ -190,7 +201,6 @@ extern const struct bpf_func_proto bpf_map_lookup_elem_proto; | |||
190 | extern const struct bpf_func_proto bpf_map_update_elem_proto; | 201 | extern const struct bpf_func_proto bpf_map_update_elem_proto; |
191 | extern const struct bpf_func_proto bpf_map_delete_elem_proto; | 202 | extern const struct bpf_func_proto bpf_map_delete_elem_proto; |
192 | 203 | ||
193 | extern const struct bpf_func_proto bpf_perf_event_read_proto; | ||
194 | extern const struct bpf_func_proto bpf_get_prandom_u32_proto; | 204 | extern const struct bpf_func_proto bpf_get_prandom_u32_proto; |
195 | extern const struct bpf_func_proto bpf_get_smp_processor_id_proto; | 205 | extern const struct bpf_func_proto bpf_get_smp_processor_id_proto; |
196 | extern const struct bpf_func_proto bpf_tail_call_proto; | 206 | extern const struct bpf_func_proto bpf_tail_call_proto; |
@@ -201,4 +211,8 @@ extern const struct bpf_func_proto bpf_get_current_comm_proto; | |||
201 | extern const struct bpf_func_proto bpf_skb_vlan_push_proto; | 211 | extern const struct bpf_func_proto bpf_skb_vlan_push_proto; |
202 | extern const struct bpf_func_proto bpf_skb_vlan_pop_proto; | 212 | extern const struct bpf_func_proto bpf_skb_vlan_pop_proto; |
203 | 213 | ||
214 | /* Shared helpers among cBPF and eBPF. */ | ||
215 | void bpf_user_rnd_init_once(void); | ||
216 | u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); | ||
217 | |||
204 | #endif /* _LINUX_BPF_H */ | 218 | #endif /* _LINUX_BPF_H */ |