From patchwork Wed Sep 25 13:13:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Meunier X-Patchwork-Id: 13812005 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 E8373C7885C for ; Wed, 25 Sep 2024 13:16:00 +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:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=r97VjhJSPp0PnTeXqeQx6AJOX2j3YrZLW1M8XQ+Ye7M=; b=Dt0e8K0Ip+k45M/aCW/W2FPpXZ 1gKDJKDpc1ObGIC95RanI7FkvRWduY/oWSyA+zjmdEnzR7C2JGC6AQCI2jZNZY6nWbxDrQ1DcpdPe bZBmWME1fiZzD3IYJ7MSsq53KLMTfk/Ikj7IQNnYenhdUx7pFmv7RTDk6FVpr1TBg4ZAE44IX4YMZ mS2yw7ftJiD1Da6+tEsgMgEoK1GVAWvwGWvQzmLWdlhXPOEkl9+ifgPxcurcHwIIc2b+EghgeSyYP o78Xsm4AqrwGIP9IY753QiFAQyn9RN6XeY4qAX6+zKAAxeB/z+1zKmV8ufx4RPh/LQoa9c+SZhiZx zET8/Q/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1stRrv-00000005K5A-31Qy; Wed, 25 Sep 2024 13:15:47 +0000 Received: from mail-vi1eur02on20605.outbound.protection.outlook.com ([2a01:111:f403:2607::605] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1stRqk-00000005Joe-06MB for linux-arm-kernel@lists.infradead.org; Wed, 25 Sep 2024 13:14:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n4CrBuQgZ+uzGuy0R+AoBLNc7eMqN7kAUUYa6LTfe3zVCgHWLXLRAckjpCrlsmp4PazxGcNsMzQ2AuuFNkKlWSk20iF8swqFH3f9W43nVbj3gZROoR5SNAHA6kPbgKRgNF7Dsbg/fYuyWDYIbuhw4HjZK4mEmgi+AohKMHz2g2aFTCcDf76MC/VtVOa85qGAYGopNLl/Vqe6MeE+UKK8d4J0wEqtAqObcjlbG78Icnxqk88PJ13xW0LLLG1MqUNAwvukoq2CFoSHBdZRHqECEwffWumM4HD+jeqTd9GfRI5gaIdKEnzD/DxjZ8cuIgaLdp4ekjM6AWcH2gOHg93c2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r97VjhJSPp0PnTeXqeQx6AJOX2j3YrZLW1M8XQ+Ye7M=; b=JK1+CbLzvV5p+0bdzZmJDwW3cnqqOMFHpisQkh/D9keacb7QTdfLppOSAwkXSm5/PBW0oDqzD2EmbTdsWb8SPbzcjVKs5/xQ+TiogDVP7DnQNE+VbAqFYfB1iZa7a0ZNlw94Re3HNU1y+axaF/xCSpKK/OzD7rybveHD7pJg+w1AqF4IrN6GxYOiiEViuijyHNMsMe6XGibSadVpGfj5Faa8aA/b+/P41VuCw9rZJ0FiaQ1EWdhDC585eUEHd8gxywpngfgzG1jDQo85PHWQdFFndECQN7vV/EJcowifmvGxC29hndJwdqT1AoUjhxjyQDncmDicEsqkntucNcYMWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia.com; dmarc=pass action=none header.from=nokia.com; dkim=pass header.d=nokia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r97VjhJSPp0PnTeXqeQx6AJOX2j3YrZLW1M8XQ+Ye7M=; b=rd6dQQIC+neJQ6yZJwbZiutqEmXeobYi9QIkugVqbBXFZAWy3C06HspQRV6PQlJG6yLzk+c3kP5J16v8pUNRKRrrakm+yEJrKeCK21oM7Amd2a7ANpw/5c90rawpVJQQiyJYdvwTFklVtNe6QEoXkcTpidUztCrMMxO03AQxh3uddR30KL9niur/NnD1GiuSC22AMFCdYehIRaFYIZa5xPTSIQzefQMuczGW6F9uBSdVZRpd1l9qXTG1U8H7BegLhbzD8fJh/V8Fcf+7WG5VRJ3ZdVvKmSh0W2jq+EpntoNIqa4t01UKggCmyowfY2l+rGZXM/FCQq/3PYHAHj/sdQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia.com; Received: from AS4PR07MB8707.eurprd07.prod.outlook.com (2603:10a6:20b:4f1::7) by DU0PR07MB9265.eurprd07.prod.outlook.com (2603:10a6:10:44f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.27; Wed, 25 Sep 2024 13:14:12 +0000 Received: from AS4PR07MB8707.eurprd07.prod.outlook.com ([fe80::887:2f82:171e:f1ca]) by AS4PR07MB8707.eurprd07.prod.outlook.com ([fe80::887:2f82:171e:f1ca%4]) with mapi id 15.20.7982.022; Wed, 25 Sep 2024 13:14:12 +0000 From: Julien Meunier To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Leo Yan Cc: stable@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace Date: Wed, 25 Sep 2024 15:13:56 +0200 Message-Id: <20240925131357.9468-1-julien.meunier@nokia.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: GVX0EPF00011B65.SWEP280.PROD.OUTLOOK.COM (2603:10a6:144:1:0:8:0:8) To AS4PR07MB8707.eurprd07.prod.outlook.com (2603:10a6:20b:4f1::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR07MB8707:EE_|DU0PR07MB9265:EE_ X-MS-Office365-Filtering-Correlation-Id: 267bbe4e-57df-478b-e3ad-08dcdd63f2ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: Cz3rheaGzPXDfVyQaRKnk7wTodIzfZQeagaiEp7HwrVry1de30jRSbFxKsOocVTCzc3tTYkSGp/94zm/QoGV55lqoy3Yh54TVFx3P5FHU+YoawqzDzqNLLhrWprzR7/YkxzLkTpHlVOQ7IRPFdUlydJxytd445gFebI4Hf0qvwhRvYVueOUgfQMmCjHO9CuGggXYu0QziYaTEOicDLo38ofgiXiHNvQqC717PG9pyjbTwZp8IzDdIxdzzWHaBYPJIn2xghpnDUaxVWYOyC0h4yGaVJ0yD5tL5lsSANEC8gcUitbBMUQf/KjGhuTGc4YQoRd2NHkbMaHh+ytdo5JUzb8wRdFy+eZw7eIQ2dAOdM5RLoJpYUOUciQqli1vCqJB0YB58RV2f2wnnvNhs1FewjnZIN/fQieLpPKMnQQ8NUoHL8kFwW0KTuEvix251bA7bo0DkO+rtDsYteMMqfEdwwJyfkq5c3R+prix21xnpNZUtz1JZdioXk1ZfeOExTXBX8CD3oufIFMn7cJaAkZ+AJsSNY/rvk8Gu8OTnuHrBnN2qLgWsBH+c1jlgSlAPL+LJrGkexg3oLciNvSIpdPKMiO8Fz6WgYg4U16kv3KIZqqyqP+IXDqFL3Psp59kWOc+zdyJnZqEUel9qKl6iH1O4lWjvAROjoozJ9DYqndu+BcN3RMdWbGOR0s1vFr7Y8Eg/UpyYqD/E1lcNNPxqb4pW2BYQMoGTmWSfJwsCCtkp6XepnN7J7MLZXAlPQAiY3HAyMQm9hW9447gBSNQgUHXMu9msfYqO4A5QP2Ns+ylGUA2TymHp4FS2FB+r1tEfMkj4UEIlntgH+13RxkgF+1NHBUhSF5idsewaNRJYIwI4c8hChwrih4Aux7h/H2SHhHlB6NLqex6RRLnSN+ycS4zqT9zLJ0IYrFXr9MJrx5T8vNKaHuasRg3QMMzV/FPtAuJaOeG6cd2LfJG/dkVIL1jOeQvMWWkP8WtRkJZjjgWLnBMN92EhkGh4yy7aoPa6+K2MwaLH//R6oKvA6MuIzbPPCR2L0tGdBNmuxqfGCBPLCPi1AXyU4fjluQhMoNC+JWkl+KdR7lZkH84je4N3SJfSchzwCUM2PkUqj9hBoPFVS4gg2bjGMsrS27QCi4AsjAut0j6a7L6U0/m2+dfP314xsi7gjLepXogh1uFvJJ1lPyNKi48EVDM1ByevVrBzucESjQjIGSbQj0JxYDdrJ7EnXa38oYyHRpDmlG4U2qI4w40sDyd/vpxT9mOLjskwSgST/tyTNMwYksSiTviNh/s5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS4PR07MB8707.eurprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bOOLLjbZ5pC0d2ft/VjwSzyfAGVgZPmvfc9kxXi3+L4O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BH4IZqM4pQ2NuICfQ97EPyewzEHAyjUPJBVaGYU+NgMIjKVlfz39jk6V0H70oqK/aNI+jo3xhWvFiUvME6SQRHbQ3IdQXWGSGMLZkXuXXGlNZD1l957KudscwYYajgMRclyJX/y5J61RDHpcGfbBjgzDZIEuXwKKWaqqYC9zGqidgm9jWlBOVWJeylGhVLI0Vb9ElX6c7S2LwbzuhopD75tmsjUu5klltvwu9RjbFUfoUkXojhaJOYAGsiQ2RXSBmEp+990vwr9OTq1wjN9NWCXRSgGGOUiSSbtK/92IrBYiLPNWQIPgWgcf4rLrSZVOjiy5u7R/mbuWv2Wr8LtocBJMbauUyKotZg3jPDHPmDfExsrinltJJ7HI8xZa1q2hQYqxr8OCYj0zUscT+nhUWhimHq0x4qnNDnLvvQWyWJzlcir6sqfAurmU0UH3O/xJNTf44i3EMc6vYR2tfQP0AiqVnip8fJfUK8nVnoglg== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 267bbe4e-57df-478b-e3ad-08dcdd63f2ab X-MS-Exchange-CrossTenant-AuthSource: AS4PR07MB8707.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2024 13:14:12.4606 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: T3MT3RW5OA8Do/8CCn+n+BCMp3cRhLKFD4TpE31V2tB5yfvXNdf2VaNeet1iphO9tQBB9HdsrWKwToy8shDXy/ofq8Sg5JDCS3MQxSuAkKg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR07MB9265 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240925_061434_488227_FDE3BDA7 X-CRM114-Status: GOOD ( 12.12 ) 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 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 --- 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; }