For tracepoint events the IP is a static kernel address.
It doesn't vary by sample and provides no useful information for
unprivileged users. Skipping setting PERF_SAMPLE_IP for unprivileged
tracepoints avoids exposing a kernel address that reveals the KASLR base
offset and slightly reduces sample record size.

Assisted-by: Claude:claude-sonnet-4.5
Signed-off-by: Anubhav Shelat <[email protected]>
---
 tools/perf/util/evsel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index f59228c1a39e..a1091d937ff9 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1503,7 +1503,9 @@ void evsel__config(struct evsel *evsel, struct 
record_opts *opts,
        attr->write_backward = opts->overwrite ? 1 : 0;
        attr->read_format   = PERF_FORMAT_LOST;
 
-       evsel__set_sample_bit(evsel, IP);
+       if (attr->type != PERF_TYPE_TRACEPOINT || perf_event_paranoid_check(1))
+               evsel__set_sample_bit(evsel, IP);
+
        evsel__set_sample_bit(evsel, TID);
 
        if (evsel->sample_read) {
-- 
2.53.0


Reply via email to