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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADE0AC433EF for ; Tue, 16 Nov 2021 09:48:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6661063222 for ; Tue, 16 Nov 2021 09:48:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6661063222 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject:MIME-Version: Date:Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PIwR+2Fnq2Ny9lM93cnanX2VKIEwj5CzwCFE9jFASeU=; b=koerQSQXfEveo9QZKtDUXLUnXp Mk3TjIhLZVC5olg0rQGy8cuMjC1/xHrmZg9seZ27SDDIoQ3YWgRJOBAsX/9/QQXXNg1WlaMm9E3Pt KXVZTZ+rt0/uA2bYJieOgSd4sa6YEPDDShh182oOCmdlL5YtpYeciVEdkgp+5IBZM/i3MKo6HeMLa Wpi8NBu0lkUOD3pUw7Z68QPzt6ah4tsdhyJiQMyHyzRZN6nHuEhwe454kFjNgRDnbbe10UtnDyHaE tc2ewiTa2puL5Bjl+N7OCPeyu4b+ugkdB9oxsxKYebANBG1u0g1cccE6Ls977xKfId66V5/bbUPIv nFhqQ8IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmv2t-0010Bz-QW; Tue, 16 Nov 2021 09:46:31 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmv2q-0010BG-A4 for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 09:46:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A34D61FB; Tue, 16 Nov 2021 01:46:23 -0800 (PST) Received: from [10.57.76.160] (unknown [10.57.76.160]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 637873F766; Tue, 16 Nov 2021 01:46:22 -0800 (PST) Message-ID: <07dbd4ac-5847-96cf-eb3c-d24561bb052c@arm.com> Date: Tue, 16 Nov 2021 09:46:20 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v1 3/4] coresight: etm4x: Don't trace contextID for non-root namespace in perf mode To: Leo Yan , Mathieu Poirier , Mike Leach , Alexander Shishkin , James Clark , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20211031144214.237879-1-leo.yan@linaro.org> <20211031144214.237879-4-leo.yan@linaro.org> From: Suzuki K Poulose In-Reply-To: <20211031144214.237879-4-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_014628_454902_A6F1139B X-CRM114-Status: GOOD ( 19.71 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 > --- > 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel