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 72618CF2579 for ; Sun, 13 Oct 2024 14:57:08 +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=uYqRfss1NBTVeKYiNPPzCz5FIOGRLaUuCoy3A+BmjfQ=; b=bGyBMnaaUF939+hKLgQbFXWNNR lR/qI7wNvWrL4bBaaUPLvyeVqUqDCKV6AioW/1iD0l3X6AF4v0bz4YkqNRgwLrTvpb6FC5DvpieLu iLKdTJhESxzU1nbdQ90PW4j8S3sfxLh11BYl4bx7cl8C91+yez1uFF+jM88HUjTj4aDEyJxw4xLxH e3cU5QsLGBDdfHmm7NwX6XdY7GnYLAierLicLZHkO8psGNJKwCmjQ7svEI3kvQ2N9iWiftGetCbWv AjiW6wbMyY/GHbPZxmhdRGAbNNNHMYclTnCc2FCeMB7GGIQZCfiEDFW7ioTZxymPfxxXCCD4tZT1Q ielu82aQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t001h-00000002oea-03o4; Sun, 13 Oct 2024 14:56:57 +0000 Received: from out-186.mta1.migadu.com ([2001:41d0:203:375::ba]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t000J-00000002oZo-2Ele for linux-arm-kernel@lists.infradead.org; Sun, 13 Oct 2024 14:55:33 +0000 Date: Sun, 13 Oct 2024 22:55:24 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1728831327; 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=uYqRfss1NBTVeKYiNPPzCz5FIOGRLaUuCoy3A+BmjfQ=; b=s15h6lrC6VPLqgaN7mFH23tSUn6W8ayRJVR8GxXO409adtjdnhAfQ7h5dW7Ce4YjmDLgpL DSf2xWD2kKeqBNxE3gNLi1Wrt3bv1hSvrOZkfFhf2daQZFWJHMntQRuIVVw1bP7sD8H59q t7oEJnp2V64HZZfecGHOpEiV+TAff+g= 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 Subject: Re: [PATCH v2] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace Message-ID: <20241013145524.GB45976@debian-dev> References: <20240925131357.9468-1-julien.meunier@nokia.com> <20241008200226.12229-1-julien.meunier@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241008200226.12229-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-20241013_075531_746930_A5FAAC30 X-CRM114-Status: GOOD ( 18.78 ) 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 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 Reviewed-by: Leo Yan > --- > 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 >