summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/bpf.h4
-rw-r--r--kernel/bpf/verifier.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index a884f5a2c503..80f2e0fc3d02 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -44,7 +44,7 @@ struct bpf_map_type_list {
44 44
45/* function argument constraints */ 45/* function argument constraints */
46enum bpf_arg_type { 46enum bpf_arg_type {
47 ARG_ANYTHING = 0, /* any argument is ok */ 47 ARG_DONTCARE = 0, /* unused argument in helper function */
48 48
49 /* the following constraints used to prototype 49 /* the following constraints used to prototype
50 * bpf_map_lookup/update/delete_elem() functions 50 * bpf_map_lookup/update/delete_elem() functions
@@ -58,6 +58,8 @@ enum bpf_arg_type {
58 */ 58 */
59 ARG_PTR_TO_STACK, /* any pointer to eBPF program stack */ 59 ARG_PTR_TO_STACK, /* any pointer to eBPF program stack */
60 ARG_CONST_STACK_SIZE, /* number of bytes accessed from stack */ 60 ARG_CONST_STACK_SIZE, /* number of bytes accessed from stack */
61
62 ARG_ANYTHING, /* any (initialized) argument is ok */
61}; 63};
62 64
63/* type of values returned from helper functions */ 65/* type of values returned from helper functions */
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index bdf4192a889b..e6b522496250 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -755,7 +755,7 @@ static int check_func_arg(struct verifier_env *env, u32 regno,
755 enum bpf_reg_type expected_type; 755 enum bpf_reg_type expected_type;
756 int err = 0; 756 int err = 0;
757 757
758 if (arg_type == ARG_ANYTHING) 758 if (arg_type == ARG_DONTCARE)
759 return 0; 759 return 0;
760 760
761 if (reg->type == NOT_INIT) { 761 if (reg->type == NOT_INIT) {
@@ -763,6 +763,9 @@ static int check_func_arg(struct verifier_env *env, u32 regno,
763 return -EACCES; 763 return -EACCES;
764 } 764 }
765 765
766 if (arg_type == ARG_ANYTHING)
767 return 0;
768
766 if (arg_type == ARG_PTR_TO_STACK || arg_type == ARG_PTR_TO_MAP_KEY || 769 if (arg_type == ARG_PTR_TO_STACK || arg_type == ARG_PTR_TO_MAP_KEY ||
767 arg_type == ARG_PTR_TO_MAP_VALUE) { 770 arg_type == ARG_PTR_TO_MAP_VALUE) {
768 expected_type = PTR_TO_STACK; 771 expected_type = PTR_TO_STACK;