aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bpf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r--include/linux/bpf.h32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8ee27b8afe81..0de4de6dd43e 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -111,6 +111,31 @@ enum bpf_access_type {
111 BPF_WRITE = 2 111 BPF_WRITE = 2
112}; 112};
113 113
114/* types of values stored in eBPF registers */
115enum bpf_reg_type {
116 NOT_INIT = 0, /* nothing was written into register */
117 UNKNOWN_VALUE, /* reg doesn't contain a valid pointer */
118 PTR_TO_CTX, /* reg points to bpf_context */
119 CONST_PTR_TO_MAP, /* reg points to struct bpf_map */
120 PTR_TO_MAP_VALUE, /* reg points to map element value */
121 PTR_TO_MAP_VALUE_OR_NULL,/* points to map elem value or NULL */
122 FRAME_PTR, /* reg == frame_pointer */
123 PTR_TO_STACK, /* reg == frame_pointer + imm */
124 CONST_IMM, /* constant integer value */
125
126 /* PTR_TO_PACKET represents:
127 * skb->data
128 * skb->data + imm
129 * skb->data + (u16) var
130 * skb->data + (u16) var + imm
131 * if (range > 0) then [ptr, ptr + range - off) is safe to access
132 * if (id > 0) means that some 'var' was added
133 * if (off > 0) menas that 'imm' was added
134 */
135 PTR_TO_PACKET,
136 PTR_TO_PACKET_END, /* skb->data + headlen */
137};
138
114struct bpf_prog; 139struct bpf_prog;
115 140
116struct bpf_verifier_ops { 141struct bpf_verifier_ops {
@@ -120,7 +145,8 @@ struct bpf_verifier_ops {
120 /* return true if 'size' wide access at offset 'off' within bpf_context 145 /* return true if 'size' wide access at offset 'off' within bpf_context
121 * with 'type' (read or write) is allowed 146 * with 'type' (read or write) is allowed
122 */ 147 */
123 bool (*is_valid_access)(int off, int size, enum bpf_access_type type); 148 bool (*is_valid_access)(int off, int size, enum bpf_access_type type,
149 enum bpf_reg_type *reg_type);
124 150
125 u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg, 151 u32 (*convert_ctx_access)(enum bpf_access_type type, int dst_reg,
126 int src_reg, int ctx_off, 152 int src_reg, int ctx_off,
@@ -238,6 +264,10 @@ static inline struct bpf_prog *bpf_prog_get(u32 ufd)
238static inline void bpf_prog_put(struct bpf_prog *prog) 264static inline void bpf_prog_put(struct bpf_prog *prog)
239{ 265{
240} 266}
267
268static inline void bpf_prog_put_rcu(struct bpf_prog *prog)
269{
270}
241#endif /* CONFIG_BPF_SYSCALL */ 271#endif /* CONFIG_BPF_SYSCALL */
242 272
243/* verifier prototypes for helper functions called from eBPF programs */ 273/* verifier prototypes for helper functions called from eBPF programs */