From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AB18CFB45D for ; Mon, 7 Oct 2024 20:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dwnTZ30pE64PPVgzu3ilNOXtrbZO989Ve0baEc4aua0=; b=oLoPRqxUnN9fWeL9/b7oIASvr/ Ii4XRVlJPmKfhjhj389c7E9cjLBMIDGGQ+CB+uf38hS7a6x+7UAVImyKAAuawCofZxJOC3uK3DUSx LtffDztCQQ3ZrczsMeU1hBdGWNR0nrMVXy7laFwekaRJHvs83CyaGIv22C2rDWtlRNoOKBLBk2ORU ddEcgtXU9H8B0pqHapCFC4bpjAaBxB7T7ylNuqWodaeWNVVPLpz8K2SeBf7JzxC9nR+2THuNHfK1C eSduho7AGQVxcly4570OvavfG0BthVCq3krx5qjjdbLNmwyRhKjujiZm2pQG8J40fG7X7Q88nqR/r IjTCSE/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxu1H-00000003hPI-3oj5; Mon, 07 Oct 2024 20:07:51 +0000 Received: from out-189.mta1.migadu.com ([95.215.58.189]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxtzC-00000003h2Y-2hsv for linux-arm-kernel@lists.infradead.org; Mon, 07 Oct 2024 20:05:46 +0000 Date: Tue, 8 Oct 2024 04:05:28 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728331531; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dwnTZ30pE64PPVgzu3ilNOXtrbZO989Ve0baEc4aua0=; b=CS2vbW2jGVUL81gcsiQvBhkWv4SlqRUuDyp4/RY5UHhO1JJNZx9E4yJF/Mh0lz8SauXDtI bwvlR8idy2Y2jfbPMrtnfw2Yre3y6zG1vUQ0XuNOSLxZciYLpbxfD9IHTrBQ0QmBRoH//3 ITiCcuBYsMK3k4LqUbm3/9lLi4LHnp4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Leo Yan To: Julien Meunier Cc: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , stable@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, leo.yan@arm.com Subject: Re: [PATCH] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace Message-ID: <20241007200528.GB30834@debian-dev> References: <20240925131357.9468-1-julien.meunier@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240925131357.9468-1-julien.meunier@nokia.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241007_130542_864098_59324E8C X-CRM114-Status: GOOD ( 20.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Julien, On Wed, Sep 25, 2024 at 03:13:56PM +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. The original commit aab473867fed is not for constraint permission. It is about PID namespace mismatching issue. E.g. Perf runs in non-root namespace, thus it records process info in the non-root PID namespace. On the other hand, Arm CoreSight traces PID for root namespace, as a result, it will lead mess when decoding. With this change, I am not convinced that Arm CoreSight can trace PID for non-root PID namespace. Seems to me, the concerned issue is still existed - it might cause PID mismatching issue between hardware trace data and Perf's process info. I think we need to check using the software context switch event. With more clear idea, I will get back at here. Thanks, Leo > Cc: stable@vger.kernel.org > Fixes: aab473867fed ("coresight: etm4x: Don't trace PID for non-root PID namespace") > Signed-off-by: Julien Meunier > --- > drivers/hwtracing/coresight/coresight-etm4x-core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c > index bf01f01964cf..8365307b1aec 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c > @@ -695,7 +695,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > > /* Only trace contextID when runs 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; > > @@ -710,7 +710,7 @@ static int etm4_parse_event_config(struct coresight_device *csdev, > goto out; > } > /* Only trace virtual contextID when runs in root PID namespace */ > - if (task_is_in_init_pid_ns(current)) > + if (task_is_in_init_pid_ns(event->owner)) > config->cfg |= TRCCONFIGR_VMID | TRCCONFIGR_VMIDOPT; > } > > -- > 2.34.1 > >