]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - include/linux/bpf_verifier.h
Merge tag 'trace-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux...
[linux.git] / include / linux / bpf_verifier.h
index 26a6d58ca78ccb2a60b91e03471e8dd1eb96df9c..26e40de9ef55f881a2282291670e810bff8318be 100644 (file)
@@ -52,6 +52,8 @@ struct bpf_reg_state {
                 */
                struct bpf_map *map_ptr;
 
+               u32 btf_id; /* for PTR_TO_BTF_ID */
+
                /* Max size from any of the above. */
                unsigned long raw;
        };
@@ -291,7 +293,7 @@ struct bpf_verifier_state_list {
 struct bpf_insn_aux_data {
        union {
                enum bpf_reg_type ptr_type;     /* pointer type for load/store insns */
-               unsigned long map_state;        /* pointer/poison value for maps */
+               unsigned long map_ptr_state;    /* pointer/poison value for maps */
                s32 call_imm;                   /* saved imm field of call insn */
                u32 alu_limit;                  /* limit for add/sub register with pointer */
                struct {
@@ -299,6 +301,7 @@ struct bpf_insn_aux_data {
                        u32 map_off;            /* offset from value base address */
                };
        };
+       u64 map_key_state; /* constant (32 bit) key tracking for maps */
        int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
        int sanitize_stack_off; /* stack slot to be cleared */
        bool seen; /* this insn was processed by the verifier */
@@ -330,15 +333,18 @@ static inline bool bpf_verifier_log_full(const struct bpf_verifier_log *log)
 #define BPF_LOG_STATS  4
 #define BPF_LOG_LEVEL  (BPF_LOG_LEVEL1 | BPF_LOG_LEVEL2)
 #define BPF_LOG_MASK   (BPF_LOG_LEVEL | BPF_LOG_STATS)
+#define BPF_LOG_KERNEL (BPF_LOG_MASK + 1) /* kernel internal flag */
 
 static inline bool bpf_verifier_log_needed(const struct bpf_verifier_log *log)
 {
-       return log->level && log->ubuf && !bpf_verifier_log_full(log);
+       return (log->level && log->ubuf && !bpf_verifier_log_full(log)) ||
+               log->level == BPF_LOG_KERNEL;
 }
 
 #define BPF_MAX_SUBPROGS 256
 
 struct bpf_subprog_info {
+       /* 'start' has to be the first field otherwise find_subprog() won't work */
        u32 start; /* insn idx of function entry point */
        u32 linfo_idx; /* The idx to the main_prog->aux->linfo */
        u16 stack_depth; /* max. stack depth used by this function */
@@ -397,6 +403,8 @@ __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log,
                                      const char *fmt, va_list args);
 __printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
                                           const char *fmt, ...);
+__printf(2, 3) void bpf_log(struct bpf_verifier_log *log,
+                           const char *fmt, ...);
 
 static inline struct bpf_func_state *cur_func(struct bpf_verifier_env *env)
 {