Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anubhav Shelat" <ashelat@redhat.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v4 1/3] perf evsel: don't set PERF_SAMPLE_IP for unprivileged tracepoints
Date: Fri, 15 May 2026 20:10:37 +0000	[thread overview]
Message-ID: <20260515201037.B7137C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260515194010.93725-3-ashelat@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Uprobes silently lose the `PERF_SAMPLE_IP` bit when `perf` is built without `libtraceevent` support, breaking uprobe profiling for unprivileged users.
--

commit 07ebb257f5c9c09215f15379588d99009f389e9e
Author: Anubhav Shelat <ashelat@redhat.com>

perf evsel: don't set PERF_SAMPLE_IP for unprivileged tracepoints

This commit avoids exposing kernel addresses by dropping the PERF_SAMPLE_IP
bit for unprivileged tracepoints. It makes an exception for uprobes since
they expose safe userspace addresses.

> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c

[ ... ]

> @@ -1509,7 +1509,19 @@ void evsel__config(struct evsel *evsel, const struct record_opts *opts,
>  	attr->write_backward = opts->overwrite ? 1 : 0;
>  	attr->read_format   = PERF_FORMAT_LOST;
>  
> -	evsel__set_sample_bit(evsel, IP);
> +	/*
> +	 * Don't set PERF_SAMPLE_IP for unprivileged kernel tracepoints to
> +	 * avoid exposing kernel addresses. Uprobes expose only userspace
> +	 * addresses so they're safe. Detect entry and return uprobes.
> +	 */
> +	if (attr->type != PERF_TYPE_TRACEPOINT || perf_event_paranoid_check(1)
> +#ifdef HAVE_LIBTRACEEVENT
> +	    || evsel__field(evsel, "__probe_ip")
> +	    || evsel__field(evsel, "__probe_ret_ip")
> +#endif
> +	    )
> +		evsel__set_sample_bit(evsel, IP);

Does this silently drop the PERF_SAMPLE_IP bit for unprivileged uprobes when
perf is built without libtraceevent support?

If HAVE_LIBTRACEEVENT is not defined, the uprobe detection logic is compiled
out, meaning the condition evaluates to false for unprivileged uprobes.

Is there a fallback detection mechanism that could be used here (such as
checking the event or PMU name) to ensure uprobe profiling continues to work
for unprivileged users on these builds?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515194010.93725-2-ashelat@redhat.com?part=1

  reply	other threads:[~2026-05-15 20:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 19:40 [PATCH v4 0/3] Enable perf tracing for unprivileged users Anubhav Shelat
2026-05-15 19:40 ` [PATCH v4 1/3] perf evsel: don't set PERF_SAMPLE_IP for unprivileged tracepoints Anubhav Shelat
2026-05-15 20:10   ` sashiko-bot [this message]
2026-05-15 19:40 ` [PATCH v4 2/3] perf: enable unprivileged syscall tracing with perf trace Anubhav Shelat
2026-05-15 19:40 ` [PATCH v4 3/3] tracefs: make root directory world-traversable Anubhav Shelat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260515201037.B7137C2BCB3@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ashelat@redhat.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox