-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix eBPF skeletons for perf trace 6.11+
This fixes only versions 6.11 and up. Perf trace tries to make use of eBPF to trace and extract parameters of some syscalls (openat, connect, ...). Take a look inside tools/perf/utils/bpf_skel/augmented_raw_syscalls.bpf.c In order to build bpf skeletons clang is required. During build process make tries to compile an example bpf program to test if tools required work (clang-bpf-co-re). Script responsible for that suppresses any warning and error that would show the issue. Enabling those and inspecting the logs we can learn that clang --target=bpf doesn't support zerocallusedregs hardening option. In version 6.12 during execution perf trace fails to load bpf program. Patch provided by Howard Chu ([email protected]) in https://lore.kernel.org/all/[email protected]/ fixes the issue.
- Loading branch information
lopk
committed
Jan 9, 2025
1 parent
4a4790f
commit 0f38e97
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
pkgs/os-specific/linux/kernel/perf/fix-augmented-raw-syscalls.bpf.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- a/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c | ||
+++ b/tools/perf/util/bpf_skel/augmented_raw_syscalls.bpf.c | ||
@@ -431,9 +431,9 @@ static bool pid_filter__has(struct pids_filtered *pids, pid_t pid) | ||
static int augment_sys_enter(void *ctx, struct syscall_enter_args *args) | ||
{ | ||
bool augmented, do_output = false; | ||
- int zero = 0, size, aug_size, index, | ||
- value_size = sizeof(struct augmented_arg) - offsetof(struct augmented_arg, value); | ||
+ int zero = 0, index, value_size = sizeof(struct augmented_arg) - offsetof(struct augmented_arg, value); | ||
u64 output = 0; /* has to be u64, otherwise it won't pass the verifier */ | ||
+ s64 aug_size, size; | ||
unsigned int nr, *beauty_map; | ||
struct beauty_payload_enter *payload; | ||
void *arg, *payload_offset; | ||
@@ -484,14 +484,11 @@ static int augment_sys_enter(void *ctx, struct syscall_enter_args *args) | ||
} else if (size > 0 && size <= value_size) { /* struct */ | ||
if (!bpf_probe_read_user(((struct augmented_arg *)payload_offset)->value, size, arg)) | ||
augmented = true; | ||
- } else if (size < 0 && size >= -6) { /* buffer */ | ||
+ } else if ((int)size < 0 && size >= -6) { /* buffer */ | ||
index = -(size + 1); | ||
barrier_var(index); // Prevent clang (noticed with v18) from removing the &= 7 trick. | ||
index &= 7; // Satisfy the bounds checking with the verifier in some kernels. | ||
- aug_size = args->args[index]; | ||
- | ||
- if (aug_size > TRACE_AUG_MAX_BUF) | ||
- aug_size = TRACE_AUG_MAX_BUF; | ||
+ aug_size = args->args[index] > TRACE_AUG_MAX_BUF ? TRACE_AUG_MAX_BUF : args->args[index]; | ||
|
||
if (aug_size > 0) { | ||
if (!bpf_probe_read_user(((struct augmented_arg *)payload_offset)->value, aug_size, arg)) |