Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Leon Romanovsky
Sun, 29 Nov 2026 12:58
Re: [PATCH V2 rdma-next 00/21] mlx5: Adversarial mode for confidential computing guests
Author: Leon Romanovsky
Date: Sun, 29 Nov 2026 12:58
Date: Sun, 29 Nov 2026 12:58
212 lines
18943 bytes
18943 bytes
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 >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads