bpf: Check types of arguments passed into helpers
[linux-2.6-block.git] / include / linux / bpf.h
index a7330d75bb94c8c40e86dab822435c60a90efe87..2c2c29b4984508971637143403a31e48e05bad05 100644 (file)
@@ -213,6 +213,7 @@ enum bpf_arg_type {
        ARG_PTR_TO_INT,         /* pointer to int */
        ARG_PTR_TO_LONG,        /* pointer to long */
        ARG_PTR_TO_SOCKET,      /* pointer to bpf_sock (fullsock) */
+       ARG_PTR_TO_BTF_ID,      /* pointer to in-kernel struct */
 };
 
 /* type of values returned from helper functions */
@@ -235,11 +236,17 @@ struct bpf_func_proto {
        bool gpl_only;
        bool pkt_access;
        enum bpf_return_type ret_type;
-       enum bpf_arg_type arg1_type;
-       enum bpf_arg_type arg2_type;
-       enum bpf_arg_type arg3_type;
-       enum bpf_arg_type arg4_type;
-       enum bpf_arg_type arg5_type;
+       union {
+               struct {
+                       enum bpf_arg_type arg1_type;
+                       enum bpf_arg_type arg2_type;
+                       enum bpf_arg_type arg3_type;
+                       enum bpf_arg_type arg4_type;
+                       enum bpf_arg_type arg5_type;
+               };
+               enum bpf_arg_type arg_type[5];
+       };
+       u32 *btf_id; /* BTF ids of arguments */
 };
 
 /* bpf_context is intentionally undefined structure. Pointer to bpf_context is
@@ -765,6 +772,7 @@ int btf_struct_access(struct bpf_verifier_log *log,
                      const struct btf_type *t, int off, int size,
                      enum bpf_access_type atype,
                      u32 *next_btf_id);
+u32 btf_resolve_helper_id(struct bpf_verifier_log *log, void *, int);
 
 #else /* !CONFIG_BPF_SYSCALL */
 static inline struct bpf_prog *bpf_prog_get(u32 ufd)