From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795957107; b=B+ClVNcy4P47J7RScFwob9Gl2jcEilX0df2jptuxwTJ8tgTKC35DnY8SbGci7nQlD4Av bMuUHQT78j2u4JNlqR0Mmm1jQ8bv6YmVaYc6NhFqOdP5bpnpPB1DnTSQMkrFC3iCjgoTx rcqLExkCLAnHftDwL9GVaDNKzmmeBlGV941synRinaAIGwQ2BdeOOvFNMaH9SpeCdxvT4 zChyrYIBLoyF62hZJQaysv5WoiqdgmeMIKKbhHpmZPxn7QObFB5Unn0sXrRoX4qgkQGBH Zb9QnO0miiC+cCC5figpbfuGUtwAn1dEhjsD1b/KL2BufvNQvIF2srCZq/4GKFCmeEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795957107; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=gte71ROIlsNr8Y36is/5RVdBfW/xM532UKELDoWeN9I=; b=zMrIgoazKTbles46y6ewIMpbAHl46QW5LDLc/4Vguqs0e3y3Jb3D0xVv0Jla0rkvLzMF w268TBsU+VhTYfUfeZF7JYOoCNRkgn1Oerlf77RopSJabbnLD0vaehEX6+YepwxfWOg4U BqURtPaGPYSiTNtLLA7cD80tSDZlKlGXg2rQ+pkYaVh+3pkzA2MjDNz2t1QwyPlV0EzsF z2tEV/nQlTh4l4NiF5J1G2DVWi/+Xkens35MiVJ9utkB5B68Q9owoeFC6cc5c4i1b5PGZ 6jR0wze8p6vrm8+DQFD6SHxlK2dsTCxQ1VPOU9myRoV6go8CfM/a3HihJ3Hz8zUV5uA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HMKZde+y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A40F6606A336; Sun, 29 Nov 2026 12:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HMKZde+y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98FDF1F0089A; Sun, 29 Nov 2026 12:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795957107; bh=gte71ROIlsNr8Y36is/5RVdBfW/xM532UKELDoWeN9I=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HMKZde+yXYs5wYVK47s2S5nrnWQ9/oyL1pY2h4sNdYcLqhsZKpgRnJTVM4Alo9Fhh 3IfXmZsHJXN+VmtXzI+6YNx58PWtCp7oDaGpBmO3xl1Mts8doJO2SnUOOREwLKkca2 tCDlK6B4MZlr4bB/bgEo2OE5D1SJaBcGgi53eowxP5F2TKUdclfFD/TuoK4Y7ZlSOH qEFrQTYeJp1k16PuPzViNG6PqU28ASGcelOjiAKUiOnFNpxHCUbsaQ8sT9jtKH1QVu 9hX1kTFfFxar0icF/IsVpBO/wRuOAgdfgk49D98R68lgNKEWt1xJ19Zp0bVoD6BP2k P7fg+b57qwQWQ== Date: Sun, 29 Nov 2026 14:58:23 +0200 From: Leon Romanovsky To: Yishai Hadas Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, davem@davemloft.net, andrew+netdev@lunn.ch, dtatulea@nvidia.com, moshe@nvidia.com, maorg@nvidia.com Subject: Re: [PATCH V2 rdma-next 00/21] mlx5: Adversarial mode for confidential computing guests Message-ID: <20261129125823.GH774860@unreal> References: <20261117170914.27410-1-yishaih@nvidia.com> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261117170914.27410-1-yishaih@nvidia.com> On Tue, Nov 17, 2026 at 07:08:53PM +0200, Yishai Hadas wrote: > In a confidential computing (CC) guest, the hypervisor and any device > assigned to the guest are outside its trust boundary. The mlx5 drivers, > like most drivers, trust the NIC: they use the capabilities, events and > completions it reports to size buffers, index arrays and pick the memory > they work on. A malicious or compromised NIC can turn that trust into > memory corruption or information leaks inside the guest. > > This series adds an adversarial mode, in which the mlx5 drivers treat > the NIC as untrusted. It is enabled automatically in CC guests, based on > cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT), with no administrator > configuration. Outside a CC guest the behaviour is unchanged. > > The approach is to keep the attack surface small rather than harden > every path. In adversarial mode only the uverbs path is exposed: kernel > ULPs don't bind to the device and unneeded features are not offered. > The data path is owned by rdma-core, which must be aware of the mode. > When it opens a context, rdma-core declares that it supports adversarial > mode, and the kernel reports back that the device is in it, so rdma-core > validates what the NIC writes to the user queues. An rdma-core that > doesn't declare support is refused a context, so it can't use the device > while trusting the NIC. What remains in the kernel validates what it > gets from the NIC. A NIC can always stop working, so denial of service > is out of scope. > > We believe that this series provides comprehensive security against an > adversarial device within rdma. Many teams at NVIDIA have been involved > in evaluating the various attack vectors and developing a comprehensive > mitigation, including AI analysis of the driver, fuzzing, and first > principles architecture review. It chooses to block and disable > functions that may open risk, and results in a reduction in driver > functionality rather than leave open potential security holes. > > The series is organized as follows: > > mlx5_core (patches 1-5) > - Derive adversarial mode from CC guest memory encryption, and keep it > per device. > - Filter the FW capabilities: start from none, pass through an allow > list, and validate or clamp the numeric ones, failing the load on > unexpected values. > - Fail the load when the FW reports fewer EQs than the async EQs need. > - Add helpers to read log-encoded capabilities without an undefined > shift. > - Add a forced health recovery, for faults the health sensors can't see, > such as a NIC that keeps answering while forging completions. > > Attack surface reduction (patches 6-9) > - Check the FW capability for every QP transport type, and accept the DC > vendor flags only on IB_QPT_DRIVER. > - Add ib_device::adversarial_mode, set by mlx5_ib from mlx5_core, and > keep kernel ULPs off such a device by clearing kverbs_provider, so only > uverbs binds. > > UMR completion verification (patches 10-13) > - Verify each UMR CQE against a shadow FIFO of the posted requests, > instead of trusting its wqe_counter. The UMR CQ is the only CQ the > kernel polls, so the generic CQ poll path, which trusts the CQE, is not > used in adversarial mode. > - On a forged CQE, keep the UMR path failed and force the health > recovery. > > Validation of FW reported values (patches 14-20) > - Set the CQ completion handler only once its poll context is set up, > and ignore completion events for a kernel CQ that is not ready yet. > - Bound port numbers from EQEs and caps. > - Bound RQ/SQ states from QUERY_RQ and QUERY_SQ. > - Clamp the log_max_* shifts used for the CQ, QP and device limits. > > Userspace interface (patch 21) > The GET_CONTEXT handshake: the new > UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED input flag and the > IB_UVERBS_CORE_SUPPORT_ADVERSARIAL core_support bit, also reported by > QUERY_CONTEXT. > > The matching rdma-core series [1] declares the support and validates > what it reads from the NIC. > > [1] https://github.com/linux-rdma/rdma-core/pull/1844 > > Changes in V2: > V1: https://lore.kernel.org/r/20261110134320.34408-1-yishaih@nvidia.com > - Patch #2: Keep the mode per device in mlx5_core_dev, set when the PCI > function is probed. An SF inherits it from its parent function. > mlx5_is_adversarial() takes the device. > - Patch #4: Reject only a negative count, as 0 completion EQs is valid, > e.g. for an SF whose max_io_eqs is 0. > - Patch #9: Set ib_device::adversarial_mode from mlx5_core during > capability init, instead of a mlx5_ib global, and read it in the > mlx5_ib checks. It replaces V1 patches #8 and #24, and comes after the > RDMA/core kverbs_provider patch. > - Drop V1 patches #11 and #15. mlx5_ib_poll_cq() checks adversarial mode > once per call, and then polls only the UMR CQ, by its verifying poller. > The generic poll path is unchanged, with no indirect call. Patch #12 > carries the rationale. > - Patch #20: Saturate max_res_rd_atom and max_total_mcast_qp_attach with > check_mul_overflow() instead of min_t(), and cap max_cqe with min(). > Make srq->msrq.max a u32, so the rounded up SRQ size always fits, and > drop the check after rounding. > > Changes in V1: > V0: https://lore.kernel.org/r/20261103163949.1554-1-yishaih@nvidia.com > - Patch #1: Do nothing in the forced work when the command interface is > down, as the path that brought it down owns the flush and the > recovery. Fall back to force teardown when fast teardown fails, as > mlx5_try_fast_unload() does. > - Patch #3: Bound log_min_mkey_entity_size by PAGE_SHIFT, and the max > mkey entity size caps by BITS_PER_LONG - 1. > - Patch #4: New patch from Dragos, fail the load when the FW reports too > few EQs to leave a completion EQ. > - Patch #7: Add a Fixes tag. > - Patches #8, #12, #15, #21, #24: Commit message improvements. > - Patch #13: Accept a non-flush UMR error CQE only by moving the UMR > state from ACTIVE to RECOVER with cmpxchg, and treat it as forged > otherwise, so a single recovery runs at a time. Narrow the > mlx5_ib_cq_stop_polling() kernel-doc. > - Patch #15: Fix the comment, the uverbs POLL_CQ command doesn't reach > this path. > - Patch #17: Cover kernel CQs that are not set up yet. In adversarial > mode, kernel CQ events are ignored until the first arm, published with > release/acquire, so a weakly ordered CPU can't see the handler without > the poll context. Renamed from "Ignore completion events for a CQ > without a handler". > - Patch #18: Move the port check into handle_port_change(), before > devr.ports[] is indexed, and drop the now dead check in > mlx5_ib_handle_event(). > - Patch #20: Use check_mul_overflow() for the kernel and user CQ buffer > sizes. > - Patch #22: Cap max_cqe to the largest CQ size the create path accepts, > and reject SRQ sizes and buffer sizes that don't fit in an int. > > Yishai > > Dragos Tatulea (3): > net/mlx5: Add capability filtering in adversarial mode > net/mlx5: Catch too low max number of EQs > net/mlx5: Add macros for reading log-based caps > > Yishai Hadas (18): > net/mlx5: Add mlx5_trigger_health_work_force() > net/mlx5: Derive adversarial mode from CC guest memory encryption > RDMA/mlx5: Reject QP transport types not enabled by FW capability > RDMA/mlx5: Require IB_QPT_DRIVER for the DC vendor QP types > RDMA/core: Suppress kverbs_provider for adversarial_mode devices > RDMA/mlx5: Set ib_device::adversarial_mode from mlx5_core > RDMA/mlx5: Remove duplicate mlx5_ib_umr_context struct > RDMA/mlx5: Add shadow FIFO infrastructure for UMR completions > RDMA/mlx5: Verify UMR CQ polling against a hostile NIC > RDMA/mlx5: Keep the UMR QP failed once a forged CQE is detected > RDMA/core: Set the CQ comp_handler after its poll context is set up > RDMA/mlx5: Ignore completion events for a kernel CQ that is not ready > RDMA/mlx5: Validate EQE port and GSI port before indexing devr.ports[] > RDMA/mlx5: Validate firmware RQ/SQ state before sqrq_trans[] lookup > RDMA/mlx5: Clamp log_max_cq_sz shift in CQ size checks > RDMA/mlx5: Clamp log_max_* shifts in QP and WQ limit checks > RDMA/mlx5: Clamp log_max_* shifts in query_device and ucontext paths > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > drivers/infiniband/core/cq.c | 19 +- > drivers/infiniband/core/device.c | 8 + > drivers/infiniband/core/uverbs_cmd.c | 5 + > .../infiniband/core/uverbs_std_types_device.c | 16 + > drivers/infiniband/hw/mlx5/cq.c | 275 ++++++++++++- > drivers/infiniband/hw/mlx5/gsi.c | 4 + > drivers/infiniband/hw/mlx5/mad.c | 2 +- > drivers/infiniband/hw/mlx5/main.c | 78 ++-- > drivers/infiniband/hw/mlx5/mlx5_ib.h | 23 +- > drivers/infiniband/hw/mlx5/qp.c | 68 ++-- > drivers/infiniband/hw/mlx5/srq.c | 7 +- > drivers/infiniband/hw/mlx5/srq.h | 2 +- > drivers/infiniband/hw/mlx5/umr.c | 113 +++++- > drivers/infiniband/hw/mlx5/umr.h | 6 + > .../net/ethernet/mellanox/mlx5/core/Makefile | 2 +- > .../ethernet/mellanox/mlx5/core/caps_filter.c | 381 ++++++++++++++++++ > drivers/net/ethernet/mellanox/mlx5/core/eq.c | 8 +- > .../net/ethernet/mellanox/mlx5/core/health.c | 95 ++++- > .../net/ethernet/mellanox/mlx5/core/main.c | 17 +- > .../ethernet/mellanox/mlx5/core/mlx5_core.h | 2 + > .../mellanox/mlx5/core/sf/dev/driver.c | 1 + > include/linux/mlx5/device.h | 20 + > include/linux/mlx5/driver.h | 4 + > include/rdma/ib_verbs.h | 2 + > include/uapi/rdma/ib_user_ioctl_cmds.h | 5 + > include/uapi/rdma/ib_user_ioctl_verbs.h | 1 + > 26 files changed, 1041 insertions(+), 123 deletions(-) > create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/caps_filter.c The series doesn't apply. Applying: net/mlx5: Add mlx5_trigger_health_work_force() Applying: net/mlx5: Derive adversarial mode from CC guest memory encryption Applying: net/mlx5: Add capability filtering in adversarial mode Applying: net/mlx5: Catch too low max number of EQs Applying: net/mlx5: Add macros for reading log-based caps Applying: RDMA/mlx5: Reject QP transport types not enabled by FW capability Patch failed at 0006 RDMA/mlx5: Reject QP transport types not enabled by FW capability error: patch failed: drivers/infiniband/hw/mlx5/qp.c:2824 error: drivers/infiniband/hw/mlx5/qp.c: patch does not apply hint: Use 'git am --show-current-patch=diff' to see the failed patch hint: When you have resolved this problem, run "git am --continue". hint: If you prefer to skip this patch, run "git am --skip" instead. hint: To restore the original branch and stop patching, run "git am --abort". hint: Disable this message with "git config set advice.mergeConflict false" Press any key to continue... Thanks > > -- > 2.18.1 >