mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
Extend the ASLR tool stripping helpers to drop register dump payloads
by masking out the relevant perf_event_attr fields (sample_regs_user,
sample_regs_intr) when the delegated tool is handling the data.
struct aslr_evsel_priv maintains the original perf_event_attr values
and is looked up via the evsel_orig_attrs hashmap so that sample sizes
can be properly parsed even when bits are stripped from the pipeline.
This is critical for bounded array copying within aslr_tool__process_sample,
which relies on orig_sample_type to determine exactly which fields were
captured by the kernel before any stripping occurred.
This allows us to keep samples that would otherwise be dropped because
they contain registers, while still obfuscating the registers.
Committer notes:
Moved now used variables from the previous patch:
struct aslr_evsel_priv *priv = NULL;
u64 orig_sample_type;
u64 orig_regs_user;
u64 orig_regs_intr;
Assisted-by: Antigravity:gemini-3.1-pro
Co-developed-by: Gabriel Marin <gmx@google.com>
Signed-off-by: Gabriel Marin <gmx@google.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __PERF_ASLR_H
|
|
#define __PERF_ASLR_H
|
|
|
|
#include <linux/perf_event.h>
|
|
|
|
#define ASLR_SUPPORTED_SAMPLE_TYPE ( \
|
|
PERF_SAMPLE_IDENTIFIER | \
|
|
PERF_SAMPLE_IP | \
|
|
PERF_SAMPLE_TID | \
|
|
PERF_SAMPLE_TIME | \
|
|
PERF_SAMPLE_ADDR | \
|
|
PERF_SAMPLE_ID | \
|
|
PERF_SAMPLE_STREAM_ID | \
|
|
PERF_SAMPLE_CPU | \
|
|
PERF_SAMPLE_PERIOD | \
|
|
PERF_SAMPLE_READ | \
|
|
PERF_SAMPLE_CALLCHAIN | \
|
|
PERF_SAMPLE_RAW | \
|
|
PERF_SAMPLE_BRANCH_STACK | \
|
|
PERF_SAMPLE_STACK_USER | \
|
|
PERF_SAMPLE_WEIGHT_TYPE | \
|
|
PERF_SAMPLE_DATA_SRC | \
|
|
PERF_SAMPLE_TRANSACTION | \
|
|
PERF_SAMPLE_PHYS_ADDR | \
|
|
PERF_SAMPLE_CGROUP | \
|
|
PERF_SAMPLE_DATA_PAGE_SIZE | \
|
|
PERF_SAMPLE_CODE_PAGE_SIZE | \
|
|
PERF_SAMPLE_AUX)
|
|
|
|
struct perf_tool;
|
|
struct evsel;
|
|
struct evlist;
|
|
union perf_event;
|
|
|
|
struct perf_tool *aslr_tool__new(struct perf_tool *delegate);
|
|
void aslr_tool__delete(struct perf_tool *tool);
|
|
|
|
void aslr_tool__strip_attr_event(union perf_event *event, struct evlist *evlist);
|
|
int aslr_tool__cache_orig_attrs(struct perf_tool *tool, struct evsel *evsel);
|
|
void aslr_tool__strip_evlist(const struct perf_tool *tool, struct evlist *evlist);
|
|
void aslr_tool__restore_evlist(const struct perf_tool *tool, struct evlist *evlist);
|
|
|
|
#endif /* __PERF_ASLR_H */
|