From patchwork Mon Jun 3 15:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13683955 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) (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 B3FC9131BAF; Mon, 3 Jun 2024 15:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.220.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717430019; cv=fail; b=Z+yQZnSJtpm1DDZNxGVD+evaU+0eR4OZ7y0b6TfB1XA8q56H7RfQKYG/BOqQgvAa9aa/rpwdeAGtsoeMSVwPIzKkMqM4tKjfuSQ5mJnwcE4zuATCJwd6Oc2cV6oXSrokyIoQkK3jRUqL8AULGCJRpGsV/ZLjXfDGwomjDBQGCf0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717430019; c=relaxed/simple; bh=INwHB+8zHtT8++2o5KHq8P3RBx2L3oZmu6Ceo7xBjUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=dqkwsW7eznDvrxGw1qXwzd6tsQjIdrbEI3qPrcMLYMiQ+0jJiaydknHvAXLX3bZo/PebtD8uahEU21xcgzozoxkP/yRIsLHJ6bpKkA+rMo+4FYH35sSITJR2SHui+UrtcJIrYhcHY8SWw8/X9C4LSLa3NyakgUkVTRemr+IKkzU= 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=OEgVS2Ue; arc=fail smtp.client-ip=40.107.220.68 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="OEgVS2Ue" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjLrbIYj5cJoxOYDJdE9t/57W55AZTEmepa5qtsYnffy7nthTFVbGYrGpCVQI4yOe3gIcxHwwflECzasgP/5PcIhKqBypX8DbzJQSt7Lh5V684Io0bFztfOZPIp8nQhif0O1tHoIkJpbAs/AiBSgQYvorRTKxWw2MGhE6EF6QNQIy9QhFNMBPrvNgBpE9R/uguWSs+X8coWgkrBMcDB7wSdvFfZZt4ZfnC/AEMUwxmcUowBoOr9MuQLVeymQhFc/MKQt99LZJGWL+ivu5MoG2XZAo8KSl2LUuFBEhSIahLjeQKtcAoOXHL6MQJRt6M5FbWizK79J9/ZxYYW93HtPgw== 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=GEMh+DoZPliQW9Sfc6rELGDgT/kare6XBBKjEW4Ckz8WiYPVz52Fg+ZCfT/rcXEjMsvIe8z+9jCrdMnLuc5wCZRu5VgYn4pLgKT3oJu9E9yjCdJqeu2qi3Hj8SU4cusGUnKupWomgcYWw5/dmpQ+Gx9o4Hre2XpL57fSYEbHXn1ZUOFZAjQi7pBlJY31+B60oM2U5HbT3/0Ws1gTqlCyJhwu02iEtEth9UGCc1ioMzJqYS40pBtxq+qdC7WEpx1WiLLUpigIrZA9GqpxlxVyjV36QE3WepkI/VUI9uC0PR27oIA1fdIEqLNBIXZhg7Rvy6F1dnc/MoY94SHw/88V3g== 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=OEgVS2UesqcgArnipCUJCqggEKffB7QL6SyBdk0lyx6v5bGbeshajOxJMZBVgVO13Mg64lK99v1oWGo3mFBRK9KmMgpmxmvCndMSFZAQABPFpd3NfSyzMBvg1i6jWe+g5/CuGaXH3VcYkgLPWRFu6Phb2vLYipQQfvuAHvziBJYNqymWrW9oGL7UiyuuJ6CWK4Do5SUUZtJXgZLlnSSWTSH1yqOE2FITZbIOB1mgMAXs720BAMEQs1EcFGdxfD/S8SMolrurzMRuhBCE7Rg6U2d+QgZ5Fm5XOaBBehp8+ZE1hjJAu3YxFS8QiW7L2a0Tnwz0g1pCh7yzLvJc802i4g== 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 MN0PR12MB6197.namprd12.prod.outlook.com (2603:10b6:208:3c6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.21; Mon, 3 Jun 2024 15:53:29 +0000 Received: from DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e]) by DM6PR12MB3849.namprd12.prod.outlook.com ([fe80::c296:774b:a5fc:965e%4]) with mapi id 15.20.7633.021; Mon, 3 Jun 2024 15:53:29 +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 4/8] taint: Add TAINT_FWCTL Date: Mon, 3 Jun 2024 12:53:20 -0300 Message-ID: <4-v1-9912f1a11620+2a-fwctl_jgg@nvidia.com> In-Reply-To: <0-v1-9912f1a11620+2a-fwctl_jgg@nvidia.com> References: X-ClientProxiedBy: YT4PR01CA0008.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::16) To DM6PR12MB3849.namprd12.prod.outlook.com (2603:10b6:5:1c7::26) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB3849:EE_|MN0PR12MB6197:EE_ X-MS-Office365-Filtering-Correlation-Id: e48047c0-2b96-4ebe-2755-08dc83e54ef1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|7416005|366007|376005|921011; X-Microsoft-Antispam-Message-Info: +WkeBJvTRcPsjKLKZb4KmWOezEFfy6+fiuA6jSzY1mZ2uHF6gBlJ4yQ8RfYmb8gsOFRetPpNSS1xN/xuuw7FuwQIQ86m1NBDhrvtzZyCNasxvZoafZlZjiCUeZLyeAEq6tWktvmwmdw2siiUQ62OdYmvNb5Be9oqelsejU/Zsixv7ZGLXlzoDD5weoh8xSyWyEVJsMVJCWqNYUxGw5h7yavL+m/+PN1WYMyS/D8qikN1sL0AxGcGC0kCklVvhFKNG6z7LUkMICiA91/U1YdrjB1cJLci8z0varZiaLtEhW8+mlPOkFtZX6T7ZW+dZP9M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Y:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB3849.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(7416005)(366007)(376005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UnAKC9FYC7lySKirO5V2kpk5abKZ8NYrxbplDQrbuQMXXwRa4F9v30Mk5sOZxWTmpcycTAYIgruYAZTMPGe2X39UMot6qYb3kC2pfvTlNKwHHwoiAeuzTwfo4mZxke45P0Ngj+3DP570LyoQzYOID+q8LVUIfBHX+GaTB5M+9XYwxyAwDGQhkrnqRJKlCQDCb0BT4MoZ1f5LImZksC6D4HbrPHsOURFfEQ+DBUnMXdF90neZ3iaCAHc68DvHWe9ggHJlJxM+8OUn72Y8UMF/l1ul6N0ij5e/UBzg68sJsLTKtlTuZOUWlunUiTTHikZlrx68MQSwP/VyIqalQePzycZS5uK3D2hWcXnnZJQHbZj016eLhj/eC8goZzykGAY5uC/mYe9WWR7gZHX5k4uZUJj7gLZKhcFhcLTs7xatmfmO6/4WK5uY8wqPxPY1PJ9wfMkORIlbSqO44QdO8NpDKMKstAb8hvUwaSxFylslsZyscY9jheai0DXjldYrLbZxAqrr/o+6IM8RKKpowtS/NN6xuRu+WB/s6A7yBYQ9ra8k18XLyC6Q7/qbtO1nn136owixWY0RaXV8cCv0WFr5F9p1m5oR9jIbuH3EzpV1A8YfBXvvCUV7jvTMKAOUxgSyojS+v7Bb09sz8cnV/YrOf395CuHPU98kuKcSSap513cxjTJUUkE4B7iHsNGxDD9q/+2/KIbM+KhtBlsdAZPwfMmz1PXYmR18vCfG+fhBLGjLzRSbt7Lgn2/r6JD/8KG+6onRxFhUn112tIynN5wU1M67X/ErNbj0B+/GRDM9ydw1XKt09gpghBwqkjU0JwBwkFbBnDs14oSxmPxfof5gpLjjOvtGIvM98GdWzyJGFut5u0eYu2Rhx0dIJ19o4tqeJzJXOn8KQ9UrYtD03IxGJzm2UK7IbDch9a1LUp49YLZeqa3QpN0kYPVKQOUNCVkaJKRhkv93OXzruvc/Wv45MwOVJgek4AgKm2Qv8XSgpacpXLw5Dyujw8zsp25JrLfzJwYukeqTrFsrkgCe8dCE4Ia9sD/De7Gye53ngdxHAl151/pSQaPR+p+puyZaUR8iee5AiU6oNY0+mCZnmPW8KWuJu4VZr67y6o+hwM6ytJzPoUO6nO70uAGjIC7xuAVdnZGqoKrIg/aTvwsu0eSL7bHMAs/mNJQgY4m9O9tBPYI+JT8UOcugJbUTGroLET5EtJloipRI2TJlTNbQ9JdlBmvH8NLzLxbPY4Ac44Q5rtC34Vw1RUMtTCre0RIc0SUc3Rsi4FLYj5sc7iNYrEFYFu2aeEy0pYy61s8dOjw+hyRWJ+/Wk2q8xtJ6RG5UDKLkUwa3LGWT5i4O9Vshpofr5OWhcIkl2aXQmKJV9GthFlmrNVUSPL/fQNNs7XanP5eO0GozH2iqJkuX2XIfjTnFlWGjdwYruhlRHrw4wlx9NVZzfhQJJOTf+9K1GOZWj5gLL3dYNnIVZfnLHHy3ZNweyufFpYSnEmZoVGnWu9nq0AZPeToa7jRkiuwF5YOx7nsiCUWsM4zQEcbJcA2veICqe9CWt/Y9t5/UnBjtLBTm07Zh/o0IB4LTk1G1NzcCNPJ4 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e48047c0-2b96-4ebe-2755-08dc83e54ef1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB3849.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 15:53:27.6277 (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: elta4oGpNdB+Kys8ELO8uaXv4qJge07gHmJlZp8fiwr2GdVauTFVL4l+g1uMmrw1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6197 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 }, }; /**