mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Add a new set of tests validating behavior of capturing stack traces with build ID. We extend uprobe_multi target binary with ability to trigger uprobe (so that we can capture stack traces from it), but also we allow to force build ID data to be either resident or non-resident in memory (see also a comment about quirks of MADV_PAGEOUT). That way we can validate that in non-sleepable context we won't get build ID (as expected), but with sleepable uprobes we will get that build ID regardless of it being physically present in memory. Also, we add a small add-on linker script which reorders .note.gnu.build-id section and puts it after (big) .text section, putting build ID data outside of the very first page of ELF file. This will test all the relaxations we did in build ID parsing logic in kernel thanks to freader abstraction. Reviewed-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/r/20240829174232.3133883-11-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
31 lines
774 B
C
31 lines
774 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
|
|
|
|
#include "vmlinux.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
struct bpf_stack_build_id stack_sleepable[128];
|
|
int res_sleepable;
|
|
|
|
struct bpf_stack_build_id stack_nofault[128];
|
|
int res_nofault;
|
|
|
|
SEC("uprobe.multi/./uprobe_multi:uprobe")
|
|
int uprobe_nofault(struct pt_regs *ctx)
|
|
{
|
|
res_nofault = bpf_get_stack(ctx, stack_nofault, sizeof(stack_nofault),
|
|
BPF_F_USER_STACK | BPF_F_USER_BUILD_ID);
|
|
|
|
return 0;
|
|
}
|
|
|
|
SEC("uprobe.multi.s/./uprobe_multi:uprobe")
|
|
int uprobe_sleepable(struct pt_regs *ctx)
|
|
{
|
|
res_sleepable = bpf_get_stack(ctx, stack_sleepable, sizeof(stack_sleepable),
|
|
BPF_F_USER_STACK | BPF_F_USER_BUILD_ID);
|
|
|
|
return 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|