diff options
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index c35ebfe6d84d..ab0cf4c43690 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -973,6 +973,28 @@ static int bpf_prog_detach(const union bpf_attr *attr) | |||
973 | } | 973 | } |
974 | #endif /* CONFIG_CGROUP_BPF */ | 974 | #endif /* CONFIG_CGROUP_BPF */ |
975 | 975 | ||
976 | #define BPF_PROG_TEST_RUN_LAST_FIELD test.duration | ||
977 | |||
978 | static int bpf_prog_test_run(const union bpf_attr *attr, | ||
979 | union bpf_attr __user *uattr) | ||
980 | { | ||
981 | struct bpf_prog *prog; | ||
982 | int ret = -ENOTSUPP; | ||
983 | |||
984 | if (CHECK_ATTR(BPF_PROG_TEST_RUN)) | ||
985 | return -EINVAL; | ||
986 | |||
987 | prog = bpf_prog_get(attr->test.prog_fd); | ||
988 | if (IS_ERR(prog)) | ||
989 | return PTR_ERR(prog); | ||
990 | |||
991 | if (prog->aux->ops->test_run) | ||
992 | ret = prog->aux->ops->test_run(prog, attr, uattr); | ||
993 | |||
994 | bpf_prog_put(prog); | ||
995 | return ret; | ||
996 | } | ||
997 | |||
976 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size) | 998 | SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size) |
977 | { | 999 | { |
978 | union bpf_attr attr = {}; | 1000 | union bpf_attr attr = {}; |
@@ -1039,7 +1061,6 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz | |||
1039 | case BPF_OBJ_GET: | 1061 | case BPF_OBJ_GET: |
1040 | err = bpf_obj_get(&attr); | 1062 | err = bpf_obj_get(&attr); |
1041 | break; | 1063 | break; |
1042 | |||
1043 | #ifdef CONFIG_CGROUP_BPF | 1064 | #ifdef CONFIG_CGROUP_BPF |
1044 | case BPF_PROG_ATTACH: | 1065 | case BPF_PROG_ATTACH: |
1045 | err = bpf_prog_attach(&attr); | 1066 | err = bpf_prog_attach(&attr); |
@@ -1048,7 +1069,9 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz | |||
1048 | err = bpf_prog_detach(&attr); | 1069 | err = bpf_prog_detach(&attr); |
1049 | break; | 1070 | break; |
1050 | #endif | 1071 | #endif |
1051 | 1072 | case BPF_PROG_TEST_RUN: | |
1073 | err = bpf_prog_test_run(&attr, uattr); | ||
1074 | break; | ||
1052 | default: | 1075 | default: |
1053 | err = -EINVAL; | 1076 | err = -EINVAL; |
1054 | break; | 1077 | break; |