From: Leo Yan <leo.yan@linux.dev>
To: Julien Meunier <julien.meunier@nokia.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
stable@vger.kernel.org, coresight@lists.linaro.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace
Date: Sun, 13 Oct 2024 22:55:24 +0800 [thread overview]
Message-ID: <20241013145524.GB45976@debian-dev> (raw)
In-Reply-To: <20241008200226.12229-1-julien.meunier@nokia.com>
On Tue, Oct 08, 2024 at 10:02:25PM +0200, Julien Meunier wrote:
> The previous implementation limited the tracing capabilities when perf
> was run in the init PID namespace, making it impossible to trace
> applications in non-init PID namespaces.
>
> This update improves the tracing process by verifying the event owner.
> This allows us to determine whether the user has the necessary
> permissions to trace the application.
>
> Cc: stable@vger.kernel.org
> Fixes: aab473867fed ("coresight: etm4x: Don't trace PID for non-root PID namespace")
> Signed-off-by: Julien Meunier <julien.meunier@nokia.com>
Reviewed-by: Leo Yan <leo.yan@linux.dev>
> ---
> Changes in v2:
> * Update comments
> ---
> drivers/hwtracing/coresight/coresight-etm4x-core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index 66d44a404ad0..cf41c42399e1 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -693,9 +693,9 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
> config->cfg |= TRCCONFIGR_TS;
> }
>
> - /* Only trace contextID when runs in root PID namespace */
> + /* Only trace contextID when the event owner is in root PID namespace */
> if ((attr->config & BIT(ETM_OPT_CTXTID)) &&
> - task_is_in_init_pid_ns(current))
> + task_is_in_init_pid_ns(event->owner))
> /* bit[6], Context ID tracing bit */
> config->cfg |= TRCCONFIGR_CID;
>
> @@ -709,8 +709,8 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
> ret = -EINVAL;
> goto out;
> }
> - /* Only trace virtual contextID when runs in root PID namespace */
> - if (task_is_in_init_pid_ns(current))
> + /* Only trace virtual contextID when the event owner is in root PID namespace */
> + if (task_is_in_init_pid_ns(event->owner))
> config->cfg |= TRCCONFIGR_VMID | TRCCONFIGR_VMIDOPT;
> }
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-10-13 14:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-25 13:13 [PATCH] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace Julien Meunier
2024-10-07 12:38 ` Suzuki K Poulose
2024-10-07 20:05 ` Leo Yan
2024-10-08 6:52 ` Leo Yan
2024-10-08 9:59 ` Suzuki K Poulose
2024-10-08 13:18 ` Julien Meunier
2024-10-08 20:02 ` [PATCH v2] " Julien Meunier
2024-10-13 14:55 ` Leo Yan [this message]
2024-10-21 12:31 ` Suzuki K Poulose
2024-10-25 17:56 ` Julien Meunier
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=20241013145524.GB45976@debian-dev \
--to=leo.yan@linux.dev \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=james.clark@linaro.org \
--cc=julien.meunier@nokia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=stable@vger.kernel.org \
--cc=suzuki.poulose@arm.com \
/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;
as well as URLs for NNTP newsgroup(s).