summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/fmod_ret_freplace.c
diff options
context:
space:
mode:
authorToke Høiland-Jørgensen <toke@redhat.com>2020-09-29 14:45:57 +0200
committerAlexei Starovoitov <ast@kernel.org>2020-09-29 13:09:24 -0700
commitbee4b7e6268be9267e288936f5b1215fec3d4368 (patch)
tree1963385635b40446667c35f61b2bf74f1c9779d1 /tools/testing/selftests/bpf/progs/fmod_ret_freplace.c
parent17d3f386757609223aa02342d29526daa67efafc (diff)
downloadlwn-bee4b7e6268be9267e288936f5b1215fec3d4368.tar.gz
lwn-bee4b7e6268be9267e288936f5b1215fec3d4368.zip
selftests: Add selftest for disallowing modify_return attachment to freplace
This adds a selftest that ensures that modify_return tracing programs cannot be attached to freplace programs. The security_ prefix is added to the freplace program because that would otherwise let it pass the check for modify_return. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Link: https://lore.kernel.org/bpf/160138355713.48470.3811074984255709369.stgit@toke.dk
Diffstat (limited to 'tools/testing/selftests/bpf/progs/fmod_ret_freplace.c')
-rw-r--r--tools/testing/selftests/bpf/progs/fmod_ret_freplace.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/fmod_ret_freplace.c b/tools/testing/selftests/bpf/progs/fmod_ret_freplace.c
new file mode 100644
index 000000000000..c8943ccee6c0
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/fmod_ret_freplace.c
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_tracing.h>
+
+volatile __u64 test_fmod_ret = 0;
+SEC("fmod_ret/security_new_get_constant")
+int BPF_PROG(fmod_ret_test, long val, int ret)
+{
+ test_fmod_ret = 1;
+ return 120;
+}
+
+char _license[] SEC("license") = "GPL";