diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2021-10-07 00:40:17 +0200 |
|---|---|---|
| committer | Peter Zijlstra <peterz@infradead.org> | 2021-10-07 00:40:17 +0200 |
| commit | b08cadbd3b8721db738d9a00ef3ce3ed667e6d9c (patch) | |
| tree | 1b44ef760764ea19f82fd80088135d23ab565d2d /tools/testing/selftests/bpf/progs/test_task_pt_regs.c | |
| parent | db2b0c5d7b6f19b3c2cab08c531b65342eb5252b (diff) | |
| parent | fe255fe6ad97685e5a4be0d871f43288dbc10ad6 (diff) | |
| download | cachepc-linux-b08cadbd3b8721db738d9a00ef3ce3ed667e6d9c.tar.gz cachepc-linux-b08cadbd3b8721db738d9a00ef3ce3ed667e6d9c.zip | |
Merge branch 'objtool/urgent'
Fixup conflicts.
# Conflicts:
# tools/objtool/check.c
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_task_pt_regs.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/test_task_pt_regs.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_task_pt_regs.c b/tools/testing/selftests/bpf/progs/test_task_pt_regs.c index 6c059f1cfa1b..e6cb09259408 100644 --- a/tools/testing/selftests/bpf/progs/test_task_pt_regs.c +++ b/tools/testing/selftests/bpf/progs/test_task_pt_regs.c @@ -1,12 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 -#include <linux/ptrace.h> -#include <linux/bpf.h> +#include "vmlinux.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> -struct pt_regs current_regs = {}; -struct pt_regs ctx_regs = {}; +#define PT_REGS_SIZE sizeof(struct pt_regs) + +/* + * The kernel struct pt_regs isn't exported in its entirety to userspace. + * Pass it as an array to task_pt_regs.c + */ +char current_regs[PT_REGS_SIZE] = {}; +char ctx_regs[PT_REGS_SIZE] = {}; int uprobe_res = 0; SEC("uprobe/trigger_func") @@ -17,8 +22,10 @@ int handle_uprobe(struct pt_regs *ctx) current = bpf_get_current_task_btf(); regs = (struct pt_regs *) bpf_task_pt_regs(current); - __builtin_memcpy(¤t_regs, regs, sizeof(*regs)); - __builtin_memcpy(&ctx_regs, ctx, sizeof(*ctx)); + if (bpf_probe_read_kernel(current_regs, PT_REGS_SIZE, regs)) + return 0; + if (bpf_probe_read_kernel(ctx_regs, PT_REGS_SIZE, ctx)) + return 0; /* Prove that uprobe was run */ uprobe_res = 1; |
