linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Leo Yan <leo.yan@linaro.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Mike Leach <mike.leach@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	James Clark <james.clark@arm.com>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 3/4] coresight: etm4x: Don't trace contextID for non-root namespace in perf mode
Date: Tue, 16 Nov 2021 09:46:20 +0000	[thread overview]
Message-ID: <07dbd4ac-5847-96cf-eb3c-d24561bb052c@arm.com> (raw)
In-Reply-To: <20211031144214.237879-4-leo.yan@linaro.org>

Hi Leo,

On 31/10/2021 14:42, Leo Yan wrote:
> When runs in perf mode, the driver always enables the contextID tracing.
> This can lead to confusion if the program runs in non-root PID namespace
> and potentially leak kernel information.
> 
> When programs running in perf mode, this patch changes to only enable
> contextID tracing for root PID namespace.
> 

The only concern with the patch here is we silently ignore the CTXTID
flag and the perf assumes the CTXTID is traced, when traced from a 
non-root namespace. Does the decoder handle this case gracefully ? We are
fine if that is the case.

Either way, we don't want to enforce the policy in the perf tool, if we
can transparently handle the missing CTXTID and allow the trace session
and decode complete. That said, your approach is the safe bet here.


> Signed-off-by: Leo Yan <leo.yan@linaro.org>
> ---
>   drivers/hwtracing/coresight/coresight-etm4x-core.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> index e24252eaf8e4..6e614bfb38c6 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
> @@ -615,7 +615,9 @@ static int etm4_parse_event_config(struct coresight_device *csdev,
>   		config->cfg |= BIT(11);
>   	}
>   
> -	if (attr->config & BIT(ETM_OPT_CTXTID))
> +	/* Only trace contextID when runs in root PID namespace */
> +	if ((attr->config & BIT(ETM_OPT_CTXTID)) &&
> +	    (task_active_pid_ns(current) == &init_pid_ns))
>   		/* bit[6], Context ID tracing bit */
>   		config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
>   

As mentioned in the previous comment, please add a helper here, than 
open coding the check.

Kind regards
Suzuki

  reply	other threads:[~2021-11-16  9:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31 14:42 [PATCH v1 0/4] coresight: etm: Correct (virtual) contextID tracing for namespace Leo Yan
2021-10-31 14:42 ` [PATCH v1 1/4] coresight: etm4x: Add lock for reading virtual context ID comparator Leo Yan
2021-11-01  9:49   ` Suzuki K Poulose
2021-11-01 10:59     ` Leo Yan
2021-10-31 14:42 ` [PATCH v1 2/4] coresight: etm4x: Don't use virtual contextID for non-root PID namespace Leo Yan
2021-11-04 15:07   ` Suzuki K Poulose
2021-11-04 15:24     ` Leo Yan
2021-10-31 14:42 ` [PATCH v1 3/4] coresight: etm4x: Don't trace contextID for non-root namespace in perf mode Leo Yan
2021-11-16  9:46   ` Suzuki K Poulose [this message]
2021-11-17 13:53     ` Leo Yan
2021-10-31 14:42 ` [PATCH v1 4/4] coresight: etm3x: " Leo Yan
2021-11-16 13:52 ` [PATCH v1 0/4] coresight: etm: Correct (virtual) contextID tracing for namespace Suzuki K Poulose

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=07dbd4ac-5847-96cf-eb3c-d24561bb052c@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=james.clark@arm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    /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).