From nobody Wed Nov 27 16:52:42 2024 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2084.outbound.protection.outlook.com [40.107.20.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 788B412B17C; Tue, 8 Oct 2024 20:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417758; cv=fail; b=HAiYNhMcu1bC+IasOTQc4jKbbZYv+Y6nx0w/J40taFRZUUKhyvNUdkYe1qwKSFHZPwuyajX5tsavYm64UJ8KBfBMwB9G8BIROyT47ZHIRZFDv/Cii07LbEq3XemX3+aZsid4FoVBQryUzF7ZHl+Xa/1ibLuRi8YEk9ogKB609PU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728417758; c=relaxed/simple; bh=oWwdgxRh3PgMhyfxXmuTOzNv7jbRnAY4BxC/MB72HWI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pSrKSLNw/Kxg+UPAzsoRqf/vOuCKFnfjjVFhJ4mviLlYMqq5K6fIEET0vzBU0vddhZ1zX3qxTuyqaCLsPRd7hqHW5xcyuHmddtliq7+Pcu7l70svWxNFKhikjT2Y+xlQBUf9MbP8ZL1iloKwW6nMJbcyu0kMsOyLR55wY++czzo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com; spf=fail smtp.mailfrom=nokia.com; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b=Qcb4CfVL; arc=fail smtp.client-ip=40.107.20.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nokia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nokia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nokia.com header.i=@nokia.com header.b="Qcb4CfVL" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YBD2ygesGKbAwGgbxBfszn438y7Qvrq5++Loq9CDk0TcLMhn8/rGNZ5FW0UlNoSFBloLQYGU7N/YgiwZ3MU9p/o9SW/kJZ/MzDVXnY9kWJDoEV+JMXu2J1agdcSeCCCpdp9t+50lr1gMAnf5hw2JZfdmD4nV/z5Q7wt6EFOcAbArZALTIg2zgVBhw+JtsBSVixN/RRt08mGkAgnM6UsyLWbQLIVDf8SC0CxU716NMr7UxvP3cxJtdPY6tIjJaT0DYFm7fijys9dkSwClZ4oShobzp6H5bgz1FrrUlwOPwusUB9o3nc68gQPdh4Qu+mCKL55T8yWZW7D8tGqDPNDuVw== 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=wzdWotbnb0kglrqvBB63QGfSYLt0JHlsQ5C5ZifPh0k=; b=qO/9pW/k9myJ3Sa/e/HBx3+eLcNPT6RaCFAimv41qReuVS/vjfoZNEhGP0gilIDmAcuXhnireXIYLm9ujHAzqbJoA6LctsA5pAx7hI+0a+bmCGocXZ65DjusOGBLckTa0YGwA4qNuep+bPcIyUo4kDGkyoJiXvlRDxn2M9nlqV+ddN1v/H9f7cnbNpqgXDnEwbWF4VXubyimwm6XWUriMLQ3yIZheGD7GcVqSjOI3YVn4kaDLZiFm9LUC6ILj/0sPUfRAPmnn4TSz4PGyxSn0I3XcM/s+PwZSfuJldL4sFKOqa77mHJuYPuE2De1dHPAyrHhd761UuGBHEmeoSvVbg== 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=wzdWotbnb0kglrqvBB63QGfSYLt0JHlsQ5C5ZifPh0k=; b=Qcb4CfVLBSnu8tdOYcs42sM62UnkABAOBcxR8/drmJT/UPa667GiECEKhAq7pw4Vy/n3z+6mH32tXPh5Q5QC+V+Tr24YHz+vdtz1qGMcT1V3XJkDKpiMZsDMv+l37JQaiNVnNh5ieUt4hrEXq0hAWlvo9RM/awyjH53pN820uOT/H1RgjEpM/9A8W8LWEFeZoit7PeUeBiYYE9bA5Ql/Lnz57GLnDrm8Ebd96JWRAr/JlEjTYXKYtulQOV/a+GdTa2xNjtpXEnCXYguyPoCGEPD2s5SCOhe/wt0jXCgk/g5YkbhbaiomwhJhT5oUnOLXUMUrANChu0ieu0uPaDvUFw== 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 VI1PR07MB9500.eurprd07.prod.outlook.com (2603:10a6:800:1c7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.23; Tue, 8 Oct 2024 20:02:30 +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.8026.017; Tue, 8 Oct 2024 20:02:29 +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 v2] coresight: etm4x: Fix PID tracing when perf is run in an init PID namespace Date: Tue, 8 Oct 2024 22:02:25 +0200 Message-Id: <20241008200226.12229-1-julien.meunier@nokia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240925131357.9468-1-julien.meunier@nokia.com> References: <20240925131357.9468-1-julien.meunier@nokia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: GV3PEPF00003676.SWEP280.PROD.OUTLOOK.COM (2603:10a6:158:401::38d) To AS4PR07MB8707.eurprd07.prod.outlook.com (2603:10a6:20b:4f1::7) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS4PR07MB8707:EE_|VI1PR07MB9500:EE_ X-MS-Office365-Filtering-Correlation-Id: b4a64217-d418-4caf-cc20-08dce7d4237f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?b+aocHE11pqjdiojvRn+ze0uJYSFlGRJX3NV5Kdfnu9kSrOOlcCNoXo71wZO?= =?us-ascii?Q?wbdU2B1pvN0IkEBqr3/z9ZcnaDYCyTCmqzeP6TmnVtzs6ItA0uzxzoWDXFVq?= =?us-ascii?Q?S1nYhBFEMsTG8bfO/qap9wP9P+3ETMNVl4ij8fucGK+06gXPEsvWUGXQRqq0?= =?us-ascii?Q?VVv7KnhFdE5fKy+HGfepX9T3xNHCBVDyZTp/SXq/R0+pEoRPmMvkifXE4RZ/?= =?us-ascii?Q?xiB2LowkVN4hmvtCvlyABBpYA5QsqYMJymD7aGlfNvh2S6jIHqOLx5fW0fHc?= =?us-ascii?Q?abSj9MPG1oaFA6PCKOELvugchbpB4P6vpIjMkksAOXSJ0cOnVBBewnUN/Wuo?= =?us-ascii?Q?l4SV7CV3WDK6biWU1qQJmX+bf4xxQsNJy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n8dvbLfCJYh9SlYjq7u6WqpYEU4iuOnGvCUsCeng=3D=3D?= 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bfbSS6XoVVYcXpI2zCDytJ3QOBAlItO0r8vrsMd9JaZsAjYZpnBSlh6FtIHi?= =?us-ascii?Q?O02iIeRKr11qr8f9KwrWVbPxj4WNmRGwhsftkCRbKSAZxrJ1xuC/Ew5MaVJy?= =?us-ascii?Q?ltEbKcreVunMK2mAC2/p2mCBMGUzRaNI+yrjnH1zcSZgnRKb4FG5NQfkqKBK?= =?us-ascii?Q?tx7WQut4NC2nkfITATNSIUT6I5xl7YnCCyr+ZOwlnV+st+ZHLvqekfxl34oL?= =?us-ascii?Q?aOaOxRaBE8kpnksIT/znodi58Ac2pf/Q4PNDiI/c+QCEHAgNvIhyUOdkSYeP?= =?us-ascii?Q?RoTiUaiGqL1/BwQAOUk41AaPCn9vCGXfQJrPCEE8sp706KQQrAMA9NEbOCgu?= =?us-ascii?Q?mprf326dwAqf97s8zvhUIrQoNdwej5dB67+5VOzj3F1+xarlL+C9aFbgH88K?= =?us-ascii?Q?0bGoaVvqu5Qy6V8mB2lb7WFVzgu9bzAEJ1+UAXKMI9icXY6VgaLcl+xcnTDO?= =?us-ascii?Q?jyO5A+hD12l1JyZoLJQulIYTKxU/RTnTJGaBAKUjpYsSbnIZzjj7iA/fLu2o?= =?us-ascii?Q?G9u54ZIfNk3J8tzI8g4LWhQFgFyEXMCWvapECU+viakB23EhMwOoYvGgc4u8?= =?us-ascii?Q?ykA9VgsqXyP2nP5IzDzl3k1eik0j1cSkabHzoiIRKcr88FPRDQD6sWP0/C7Q?= =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vlccOgEQfQMcf4KUm5?= =?us-ascii?Q?BaRmfSNwtZce+MPxObZJgeMQznNs6DgrHwv3alNmc6KoZebsQOQZubETogIZ?= =?us-ascii?Q?wQ=3D=3D?= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4a64217-d418-4caf-cc20-08dce7d4237f X-MS-Exchange-CrossTenant-AuthSource: AS4PR07MB8707.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2024 20:02:29.5658 (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: J4eNaXNLAhQVs/jApUTi5ltpokDD0LVUba0tQDw9I42lLrWDduuKn4g4bHx2CPRmq0Ls/9uJ2dfYBkQ8rv0pS/CY3YF6E0vuHWT2dXSLWWE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB9500 Content-Type: text/plain; charset="utf-8" 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 na= mespace") 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/h= wtracing/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_dev= ice *csdev, config->cfg |=3D TRCCONFIGR_TS; } =20 - /* 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 |=3D TRCCONFIGR_CID; =20 @@ -709,8 +709,8 @@ static int etm4_parse_event_config(struct coresight_dev= ice *csdev, ret =3D -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 name= space */ + if (task_is_in_init_pid_ns(event->owner)) config->cfg |=3D TRCCONFIGR_VMID | TRCCONFIGR_VMIDOPT; } =20 --=20 2.34.1