From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.51 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795939285; b=2iZaGautZUVNCq0C6A7lFp7RS4+vxNvqW+tUbr8ytMoXyUbkEytvUzbCXFpgzbhGz2MP 0fVXLBzszWax8ZOZdUnA24CVBIpDSkBX53dLSbutfHFUo/sf5QqaR00A3p0ER6nbyeIZj 9YNS2CWoRl3UEm+ZDsg36trgVm1Gr4rvcLj1Ta8afnrRynD6XIXnWR+yL0AuALJEjcanU CXL3qmal66AQppMNMzDz+xExB/cJq7WuXYlnAE8ECO8NlgWiilLs/bgcBqqZ8BJqTSRcN jyE1KXxvhYlxHQkdFBgnMVEBiOd5jnP1K8VesA7mpsqTKta4VLSu5fC8TJVhlCG2qLg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795939285; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:CC: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:X-Originating-IP:X-ClientProxiedBy: X-EOPAttributedMessage:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay: X-Microsoft-Antispam:X-Microsoft-Antispam-Message-Info: X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=zgP22/PBr5YnsEITu+sriy+HdfOrY4Qid/r4sZRjLVY=; b=2WSvXUZYWNUp6iq/0PGCQOw8/+N/tTqrtQhwCsnbPkkh4FiS51sfFHOfz+pDCN8x2bmS mowBM/Zx4tQU2y61ezk/rWxNaRJDyIUkADuFb7gIl31w6n33l7crk84Gu9ai0gBY1GBTv PkxWHLxvyVoW+zmKi3Q0Y5pf+CSu6M77s+9uw/tafqFAX9R8YVSW5Aae9F/SE5/49axSc LCCxn6TKS6fVBFrFRtEtZ7PSBBNOW9zvhWLJ3qkukvimudQGzg0mX3vwvMDWwWJ5hNXym ymaawAHW90ne/Y9EUqcMI2cTKPY0Bpk6h151Inh7q4TmyIazYrkObHnKqROkEDBkiQA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=K9OmsX5T; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.198.51 Received: from CY7PR03CU001.outbound.protection.outlook.com (mail-westcentralusazon11010051.outbound.protection.outlook.com [40.93.198.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FE64606A31C; Sun, 29 Nov 2026 08:01:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6FE64606A31C 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, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=K9OmsX5T ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sxlR2ern2gx797pTutuE9z3+6eNBsbKnIfjYGcXIK0Os6Y2VsX0ive5OuwJukNYGyiNhqnASY8qxl6R6yuCstan5YvEGV+ix6hAwVo+P05LPcAHoUBt8EuiWZ3O8xScwnZE1IovHnLfTywDgADF7NHOFR49WwfWksEuKuLU/IqwBgdY4u+qgJyLV4Rufoju2tCy/ytXQUdsnoeCC2HOF/8xAX/zHx9DbKFle4u7Q+4vT//fjOnnYH80LItb5szhPeVzUX+Xn+pzvrDJQDxq8X8WITu0wkAKzGrvh8E6Ljf/RXqh2ZC1x97FHOSA2xkUkMBg4ZcmOmO0JT/LwQLa5mg== 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=zgP22/PBr5YnsEITu+sriy+HdfOrY4Qid/r4sZRjLVY=; b=IbwMFFXrJVh/LxwO+/EA/PUUUnXcr+3wsOchiGQy37qJT5xAvq1+z1Gh5d4vl71u+Z8sDY3oByAW9VoPEWk9ilAXBQ3eUUfbdRTEYs25yLXvYUWSbIg+OiptgUgSJy0/yguhcMotDtZ9KpDJ5g3EQlIm10k/llLkxj5T7PJV1XhxNrBcZcHAw7i7OQsr3o7+/zAqGiomUeXx/Z89hLJcdlZuTk395srhlVXI0wJ2q++mBz1qOSV7FiNFiKahmcbop9a4dqURemfX7SMG9ws90xjQE5L6ciDlxepYDcR/3VUmPbS5loQ3bYU5ENtNDDl+j2nAyqSgDYZQD20HnJFrjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=zgP22/PBr5YnsEITu+sriy+HdfOrY4Qid/r4sZRjLVY=; b=K9OmsX5TvesxJZpw9O+/45DNVtAG7S+ldA2cw80cVU22qEbQcTFpn4IUIw6EOmvSRb62ye9tAT+7nNEqeOLKEB+TjDQz0wDhY4EOYi4mly7m1TEujAmFjQR0t1/GRC4h8XLKmXZSrMNkRU4IMe2pr4Y7H0Huk0KtH25IJJl4hwy4B27X+fY6a9TvpZIaieFu11K45aG6OeocQ8rk74ltVbLpgK8XZmNuz55kLtuiLbJNH6wpcyrmZ2zok7cigBstYTkm14kSwPBjkKg601THBOuRloCYmEHdENBDgcn+jZIA8oClzp06Mpa7Qyodvg5esYYPZT7mf07HHDeJizS/tA== Received: from DS1P221CA0001.NAMP221.PROD.OUTLOOK.COM (2603:10b6:8:451::6) by DM6PR12MB4354.namprd12.prod.outlook.com (2603:10b6:5:28f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Sun, 29 Nov 2026 08:01:20 +0000 Received: from CY6PEPF00000048.namprd03.prod.outlook.com (2603:10b6:8:451:cafe::3) by DS1P221CA0001.outlook.office365.com (2603:10b6:8:451::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.662.12 via Frontend Transport; Sun, 29 Nov 2026 08:01:20 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY6PEPF00000048.mail.protection.outlook.com (10.167.247.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.3 via Frontend Transport; Sun, 29 Nov 2026 08:01:20 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Sun, 29 Nov 2026 00:01:05 -0800 Received: from [10.221.197.139] (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Sun, 29 Nov 2026 00:01:00 -0800 Message-ID: <9f4d06db-3c65-4c28-be31-ff7e35f93f81@nvidia.com> Date: Sun, 29 Nov 2026 10:00:48 +0200 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT To: Leon Romanovsky CC: Jason Gunthorpe , , , , , , , , , , , , , References: <20261122073156.GA12665@unreal> <761ca80e-a772-41f3-b8e9-cc332e4ba5d9@nvidia.com> <20261124125327.GR14811@unreal> <20261124125950.GC9566@ziepe.ca> <20261124133353.GT14811@unreal> <20261124134751.GJ9566@ziepe.ca> <20261124140906.GU14811@unreal> <20261124143024.GO9566@ziepe.ca> <20261125090309.GY14811@unreal> <20261126155723.GT774860@unreal> Content-Language: en-US From: Yishai Hadas In-Reply-To: <20261126155723.GT774860@unreal> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY6PEPF00000048:EE_|DM6PR12MB4354:EE_ X-MS-Office365-Filtering-Correlation-Id: 489d266c-d6c9-4dc4-18c3-08df4deef438 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700016|376014|23010399003|22082099003|18002099003|261021135927099003|261021121427099003|261028144727099003|261022105027099003|261026140227099003|4143699003|5023799004|11063799006|56012099006|10067099003|261102123227099003; X-Microsoft-Antispam-Message-Info: 1sLNretUE8KjOABxeEkJgK7+ktaaE27FsGpfmpoaO5d0Vnm0RMG+NuOWn7kkzNTxE2Xgnw6bW05Wt8aTeswK7rERcr7zSBL47lriW32ssCZ1a515i/y0XOAFDs0FqxWgaxTI+cS1IdWxJUqQ/beu6yuiQcV4nGyDjKUshbCffePtcK/fRpzJCyHQKOKs5Ja837sk1TO/9V7oVtt06ZOit7xPjobrMrA8fHwhMpCijmVgVpU/+8106yBmp3pS1fgrJrlwdZ2t3J3WMsuPfXj7aw4Dac0AH86YaYTpMiA8k1aa+o6/MeYS/cfBlrEA0VdTaKu31qL88sXNZq8CpCwV1AL7skK1SllmkeKWRfr/kZlz5VsVG98aDBm6l4AathTmY+CmZ729pv2npD8qokqamXIjLAgen56OGpzun2x8JgahUQK/k12ejs75BepHOP6fXbO6Gc7RYtKHVL8O+WRLVVBLit1FNHRexW4g+QvDXuxJ2quVbUvvpTlc97Q1PogObnrTOdRPE+R6gFeUEbvO8Ph7kvlHnijv1U8T/H+vHU61sz6HMKjco0k9qYQzKc2yVql5ypLm85Ud8+9oIGnyKAJBHf4jt6d8oEJOFgx/gdDzCdCY/QoW7xCGB+RJrGiJDV+In9Fmya2Za+tvK8pOUtvD9S6KI1C5RnOvDFlkocZ+5xvCdtRr/cGVLtK9eoLKoeuGqjoSnxNNi5TxAUbnbg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(36860700016)(376014)(23010399003)(22082099003)(18002099003)(261021135927099003)(261021121427099003)(261028144727099003)(261022105027099003)(261026140227099003)(4143699003)(5023799004)(11063799006)(56012099006)(10067099003)(261102123227099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qdhfTt+VHJhTa7OSn4UAtvllKqNB3BdQ+ckCvQrJzPJRmM2R4qgFn065iGdfRO3IYKqP/QZ8wR5nUH48qEG+eraAwa/i24RnFozR11p/jG84UOYG8tlIYgze91GHjkbkWGJuDIKrAmkBH79zGnuwUGhntZRSw+FSf3Vl3j08J8LW6qPYZSQBRF9NqwHAVGmwpGy3eUTexh8H0K75/MnmTiJ9qUNBlX5I4xVmGM4aQmSOqNCky2y/ig6CMXI2jyEEc74veHgNX6sYyhk6G5hT3IHz00UTyOL++BMfIxxQX3rZTtv//bd6jgr+lfxjkDBYu63kEmLlpvEJdt80GGO7o/RIZVop2Chu96Bke3TPCbo/Om14HyezDZrtYvqyV88MfmesC0VfK/UgUvYjV+jjlSMcezxIE/QP71dXLozc8ReAXDrFBxfwJomLxzjFOFT0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2026 08:01:20.3831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 489d266c-d6c9-4dc4-18c3-08df4deef438 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY6PEPF00000048.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4354 On 26/11/2026 17:57, Leon Romanovsky wrote: > On Wed, Nov 25, 2026 at 01:41:50PM +0200, Yishai Hadas wrote: >> On 25/11/2026 11:03, Leon Romanovsky wrote: >>> On Tue, Nov 24, 2026 at 10:30:24AM -0400, Jason Gunthorpe wrote: >>>> On Tue, Nov 24, 2026 at 04:09:06PM +0200, Leon Romanovsky wrote: >>>>> On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: >>>>>> On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: >>>>>>> On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > <...> > >> Would the below commit message make it clearer ? >> >> RDMA/core: Report and enforce adversarial mode via GET_CONTEXT >> >> In adversarial mode the NIC is not trusted. The kernel protects itself, >> but user space has to protect its own memory as well, since rdma-core >> parses HW-written data, such as CQEs, directly. Hardened user space >> might use a different data path with extra checks, so it has to know >> when a device is in adversarial mode. >> >> An rdma-core without this support uses that data without validating >> it, so on a device in adversarial mode the process runs without >> protection from the NIC, a silent mismatch. Such versions are already >> released and can't detect this, so fail GET_CONTEXT in the kernel to >> turn the mismatch into a visible error. > > This part is fine for the rdma-core-to-kernel direction. You should also > explain why the kernel-to-rdma-core direction is important. > > The main reason is that rdma-core wants to move away from sysfs files. > They are unreliable in RDMA containers, are prone to races with device > renaming, and provide no generic way to locate the trust-level sysfs file > for an IB device. That file is buried under the device's PCI directory. > > Thanks Thanks, Leon. How about the below? RDMA/core: Report and enforce adversarial mode via GET_CONTEXT In adversarial mode the NIC is not trusted. The kernel protects itself, but user space has to protect its own memory as well, since rdma-core parses HW-written data, such as CQEs, directly. Hardened user space might use a different data path with extra checks, so it has to know when a device is in adversarial mode. rdma-core would like to move away from sysfs files, so the mode is reported on the ucontext rather than through the trust-level sysfs file, which has no generic path from an IB device, is unreliable in RDMA containers and races with device renaming. An rdma-core without this support uses that data without validating it, so on a device in adversarial mode the process runs without protection from the NIC, a silent mismatch. Such versions are already released and can't detect this, so fail GET_CONTEXT in the kernel to turn the mismatch into a visible error. The kernel reports adversarial mode in the GET_CONTEXT core_support, and user space declares its support with a new optional GET_CONTEXT flag. In adversarial mode, a GET_CONTEXT without that flag fails. In generic mode, nothing changes for older user space. Yishai