From patchwork Mon Jun 24 22:47:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13710207 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) (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 2C21F1A254F; Mon, 24 Jun 2024 22:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.89 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719269265; cv=fail; b=nfEwdsWUugJ0iOoYBusdZ7ULOUT+rwZSQ1v/R9LBP8ydThscOoagxFNtZ+ofS/Epv3yk/jVYGf/AzcZBOIUy3/vUn6ZlcngCSNTTU/BDld99SAxArkq8pCRceBPPqlFqewLv/oa83AReduTUgTTbfTfWeQyMCFHChW1OgI2oKaI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719269265; c=relaxed/simple; bh=INwHB+8zHtT8++2o5KHq8P3RBx2L3oZmu6Ceo7xBjUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=YbdMbqiWSNEFjhcowYw84jm6GCRR3R9nbCusWQCINMYCdSYfXmat6pSivJdeKGaKpDgjFa87nJ67f4LOMxbkJ+2qzvC3g8b+4CcjE6h7itKcJBwG3/NjBxb5REBiGedFFP8CatKoNBcleRxQAbb8TUxZUngmydEmj/IjV4upXJ8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=RaU8uSGX; arc=fail smtp.client-ip=40.107.94.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="RaU8uSGX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MZ+axd7F04x+a4nylIFBes30JLsvkqU+2Crv0POhZrw36WLb1lUrqcMRW7fPUyuSZeChF90xMMnRqVougJkCODUuMxnlPntotU/BB2mLmsN79EBvpcK9884nLNqvqB3u0RUUM6Lu9FBGBqwlZSiIg51Dd8BGa7xN4xyZf/TsmjTxWK5CnGHbshESqEm9xuDQI/5GC2pV/Oi0nZPEhftXFi+aG4KgGJ4zLwCWZbgPg1tqm/tjROKeA7FZIeztQE5HiUu69eG5cvSV+Bsfys9t5t+ThoMGi/BiisPuO8+7RLyTRAX4I871H1itoVbU9xkQ3Iyn8dTS9MKc/rL9xi5qag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=5EJ40bburIyBhpGzbZEasBszAf0xIC7aH42lNUBqrJE=; b=cGkZPsA7K1FIL+EYEffdv8iMC09vRUohBCCqkc72hQFRxsnMZLpMOEpfzL494Qnpqvgutao+IgfdVK4hUR4EMcwvPL0wFvHNpCo+/cmc/hzFtq3RM4e+m0Dpq6AFP1DlT17xNRN+tfDfxBWNdxlmh7aFRC/dABN3+TJ7EnBC4b8Jca/4hA3nQnJx/6v/3DBUKmHHftegGzw3cp7H347PjoFm0USGK9fw9U++6RQMpXkqBti3WDoR6N+lRKYIPkMVD0Labs3GNsxSIYdlfHVzqq/wtuHxcZiQe2fVoGcAVkhV8SHuwf21MQgs1c1iEFYP4dFX8PlinN0n5Ez+d1NBMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5EJ40bburIyBhpGzbZEasBszAf0xIC7aH42lNUBqrJE=; b=RaU8uSGXvrCsUgnUkZtS3P4WmemA7LqxWl9nnYbUj/b8dqWNCnfnNMG/q/DhaMY9QOKn3x2l81cwCO2Q8nQh+Z1iKkSqXjvfq/fTgRV+S9KJkeyRNyPQ2z5fBFplFr44aclNuI/N9fwi8dwKMx8Aycjc/TPYfsGaICAdDe8ctooIsRKH7yNIhIt/KsM6uH6vYnTynxCOC2FO7g+zHdFIE1HsIgBwJUW4kMY75AmDHt+dkyJ5iECZiTAeVtH3jNj4zxSJpOdx22r5QQYkHpFbZKnKiPZ3E33YR+sVe71E1M6HyH7i9mCYkQgQSFGUBqlLX4mP0H0+vAzCnwjKK7hjhg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) by DS7PR12MB6024.namprd12.prod.outlook.com (2603:10b6:8:84::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.30; Mon, 24 Jun 2024 22:47:40 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%6]) with mapi id 15.20.7698.025; Mon, 24 Jun 2024 22:47:39 +0000 From: Jason Gunthorpe To: Jonathan Corbet , Itay Avraham , Jakub Kicinski , Leon Romanovsky , linux-doc@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , Saeed Mahameed , Tariq Toukan Cc: Andy Gospodarek , Aron Silverton , Dan Williams , David Ahern , Christoph Hellwig , Jiri Pirko , Leonid Bloch , Leon Romanovsky , linux-cxl@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH v2 4/8] taint: Add TAINT_FWCTL Date: Mon, 24 Jun 2024 19:47:28 -0300 Message-ID: <4-v2-940e479ceba9+3821-fwctl_jgg@nvidia.com> In-Reply-To: <0-v2-940e479ceba9+3821-fwctl_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR05CA0065.namprd05.prod.outlook.com (2603:10b6:208:236::34) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|DS7PR12MB6024:EE_ X-MS-Office365-Filtering-Correlation-Id: 5046168f-17e6-461b-0daf-08dc949fa412 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|1800799021|7416011|366013|921017; X-Microsoft-Antispam-Message-Info: F/7ELUV5AUv3RRj7b3ObmLKncdoPRkHEihmZgF4cfiZRscJAI95RKJC2HCGl0y7LbU7NorRgqZquQzoVAWVoib6kYdZj1tGxTWwCm5RAMI+a4w/4wJJEKWPBo636vCPxWgonAqNzUJXg9pcmCJI3xOE0S/eoVyvbmrAUeYijbOinlN6Xnst0tPeHVmRDzECnuXZTG15ywcEAQkZc0qkKglf+cCZFYqWkt9UmxD+03mLWoXyc4XjqzVpTtfoiVzhxR25WxYLmS69E4BndsrR7goaciTfNYyRl4BSMrhc4AaWaRMN6c6zzR5Sw6sOyrnR7CYbfVtAlimS11lpKivtMd0sdE2Y4DV44Js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:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(376011)(1800799021)(7416011)(366013)(921017);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3tk9XbElGYVJXiFFCkNXc4rNDgPyhbegIOVR9/XzoZDUTitoA8+OSrquG7sSBRs4AahpCs7nYh86pfFCQLA1B8UD2VlWKg9oA1bucrsyT1L8CscZMghzdHk6UEMGRwbVf0kSZaMjy/dP8BMkq8gtGsUqgl6F/3lKd8IxlnEA+fe8C/un/JcdzIO+N2FIp+WLp8VRVObtGmDkA4v7GihMJ8T/6bPMzAloVPq41mZbVJZFVCkmNNn/1KHvQAu/WPbOe/hfBJqPVtRuBl1kOzmmccE/izRNsDLPLKJ0c4PwC0RNVTjYn6TpYbBi3AA80F0ZlxjPagz6TXufJWQrsHmaa623grbsLBfk2A4Riui6YbMMEtvMmV1gwnpvAaW4WMJ8fcrogPLEiFaVeuWiSi2ScHDPwj881GNtQaGXtTzCXENRIYoUJb8ntDvTiY9KPSkPqjjAp7rj0OgfWhxIsqv3MGfyS/FYZzJ2Sa1yHnK/Xwm3MDij5YzHoGfLTHymE7122/wYdad4JWxin21WuQX+XXkzLiMYBNt0aecWrhDYIuoZwtaMjwOIKQahX+HirmgjD1AT/ClrTxzT0svxqh3gWgPCCJ+uIZGcu64GHE9T+2PjZs7dG+FaTMEGWtpU7IbD/ELfSNAYxSIMhblMhAjR8DmZ9fTPeINyUx5Of9GwY9+qEzbjQW7hTs4JEF4dSv5iKgUFHjeIvwSY2mbHLVYbqJ3ftQ5g90I3d6JtZddf34Wq71KCIpmjEqqvBBKJG78U92jZ7WE+MftJJFzTJPnOYuhYbHg8FJ5EYX/iUF3zF4HH9uihosGQ01gHbbj6o7gflCEtlR63/kNy6OOIy7Lrivkfbt43CNmQBVlnQ4qhiN84aO89laFBPZnMGNsdTl78pSJwZLGiSTdXZzq8HLr5EkkQK71SWUxfVuxD9Ur60G05757ZhTrrhy1y97uxJMwebwO5StL9z6CvUB/ehq+g80knhK07C8MY5SBnf4hi80T8fxwUzW0mAcKbEiDu/P+5sLh1Sj56nMr2axrF7vrTBLw7l3XnPbxkPp6uwa89hnm7P1ayFZ8Lp3mTGEXN/VgTyQqK4VblwUP7uYIEzxa+cU/XDcw5Y0pzo/ZKyBtaNmgQVSOBWxK6zmN8v/p9gv2m4wHv67LMU9P1x0IwmI584JTTLGpyYyPxUv48sLUw6sQdjkmx12ApYLEsot/Q473D3qiIpvTtp+qO4w58JsRPV//85L2+l4c1o2eC//V9+TwhV6R/Sxpxg5i8EQ4TFLIeJjN02rYLe1tErx/JgYjykqsayu1OEgyG0c7+LFHAQp78RF7IoV3PCUnUFcZ3F24m8KLHL5o+N21ERj/wfEi+Lrwjf0yQOBIYaUAYinUz48Js4yO4udcL1sRKi4LpKUvoLGt2yS6plGYMLedHs8hGvR3fd3PIm/8iQy19zwewx7nM5PuU8p27bcrvEeBzUMIq+e90NWjSCxJ7PNIcSn1aLSplZWpcMqTNvsm8P5B08GCM95Y1F6INZeXetVoZfMu0ngFDG8qbqUvoyMbkMluGRmtHo/ukmhNw/Rcx/SzKE3lSoscp58g+7SsZmiODlM9Q X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5046168f-17e6-461b-0daf-08dc949fa412 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2024 22:47:35.4593 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uoPo291rP/g9YpGQD0F2y3dcUPeCXdpq+RAL/5Y7O0oVnKJD29+WqXn6GURAYnqV X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6024 Requesting a fwctl scope of access that includes mutating device debug data will cause the kernel to be tainted. Changing the device operation through things in the debug scope may cause the device to malfunction in undefined ways. This should be reflected in the TAINT flags to help any debuggers understand that something has been done. Signed-off-by: Jason Gunthorpe --- Documentation/admin-guide/tainted-kernels.rst | 5 +++++ include/linux/panic.h | 3 ++- kernel/panic.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/tainted-kernels.rst b/Documentation/admin-guide/tainted-kernels.rst index f92551539e8a66..f91a54966a9719 100644 --- a/Documentation/admin-guide/tainted-kernels.rst +++ b/Documentation/admin-guide/tainted-kernels.rst @@ -101,6 +101,7 @@ Bit Log Number Reason that got the kernel tainted 16 _/X 65536 auxiliary taint, defined for and used by distros 17 _/T 131072 kernel was built with the struct randomization plugin 18 _/N 262144 an in-kernel test has been run + 19 _/J 524288 userspace used a mutating debug operation in fwctl === === ====== ======================================================== Note: The character ``_`` is representing a blank in this table to make reading @@ -182,3 +183,7 @@ More detailed explanation for tainting produce extremely unusual kernel structure layouts (even performance pathological ones), which is important to know when debugging. Set at build time. + + 18) ``J`` if userpace opened /dev/fwctl/* and performed a FWTCL_RPC_DEBUG_WRITE + to use the devices debugging features. Device debugging features could + cause the device to malfunction in undefined ways. diff --git a/include/linux/panic.h b/include/linux/panic.h index 6717b15e798c38..5dfd5295effd40 100644 --- a/include/linux/panic.h +++ b/include/linux/panic.h @@ -73,7 +73,8 @@ static inline void set_arch_panic_timeout(int timeout, int arch_default_timeout) #define TAINT_AUX 16 #define TAINT_RANDSTRUCT 17 #define TAINT_TEST 18 -#define TAINT_FLAGS_COUNT 19 +#define TAINT_FWCTL 19 +#define TAINT_FLAGS_COUNT 20 #define TAINT_FLAGS_MAX ((1UL << TAINT_FLAGS_COUNT) - 1) struct taint_flag { diff --git a/kernel/panic.c b/kernel/panic.c index 8bff183d6180e7..b71f573ec7c5fc 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -494,6 +494,7 @@ const struct taint_flag taint_flags[TAINT_FLAGS_COUNT] = { [ TAINT_AUX ] = { 'X', ' ', true }, [ TAINT_RANDSTRUCT ] = { 'T', ' ', true }, [ TAINT_TEST ] = { 'N', ' ', true }, + [ TAINT_FWCTL ] = { 'J', ' ', true }, }; /**