diff options
author | Ilya Leoshkevich <iii@linux.ibm.com> | 2023-02-10 01:12:00 +0100 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2023-02-10 15:21:27 -0800 |
commit | 202702e890a41412a7de970b84a970ba1d5001c9 (patch) | |
tree | 2831804e722ee2d67d49e881ca0a9e6420a7e514 /tools/testing/selftests/bpf/progs | |
parent | 907300c7a66b3b58fc0039402aa14e0b9f11aad6 (diff) | |
download | linux-stable-202702e890a41412a7de970b84a970ba1d5001c9.tar.gz linux-stable-202702e890a41412a7de970b84a970ba1d5001c9.tar.bz2 linux-stable-202702e890a41412a7de970b84a970ba1d5001c9.zip |
selftests/bpf: Attach to fopen()/fclose() in attach_probe
malloc() and free() may be completely replaced by sanitizers, use
fopen() and fclose() instead.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230210001210.395194-7-iii@linux.ibm.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_attach_probe.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_attach_probe.c b/tools/testing/selftests/bpf/progs/test_attach_probe.c index a1e45fec8938..3b5dc34d23e9 100644 --- a/tools/testing/selftests/bpf/progs/test_attach_probe.c +++ b/tools/testing/selftests/bpf/progs/test_attach_probe.c @@ -92,18 +92,19 @@ int handle_uretprobe_byname(struct pt_regs *ctx) } SEC("uprobe") -int handle_uprobe_byname2(struct pt_regs *ctx) +int BPF_UPROBE(handle_uprobe_byname2, const char *pathname, const char *mode) { - unsigned int size = PT_REGS_PARM1(ctx); + char mode_buf[2] = {}; - /* verify malloc size */ - if (size == 1) + /* verify fopen mode */ + bpf_probe_read_user(mode_buf, sizeof(mode_buf), mode); + if (mode_buf[0] == 'r' && mode_buf[1] == 0) uprobe_byname2_res = 7; return 0; } SEC("uretprobe") -int handle_uretprobe_byname2(struct pt_regs *ctx) +int BPF_URETPROBE(handle_uretprobe_byname2, void *ret) { uretprobe_byname2_res = 8; return 0; |