Skip to content

mlx5: Adversarial mode for confidential computing guests

Yishai Hadas linux-rdma netdev sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23net/mlx5: Add mlx5_trigger_health_work_force()drivers/net/ethernet/mellanox/mlx5/core/health.c include/linux/mlx5/driver.h+73 -112 replies
2/23net/mlx5: Derive adversarial mode from CC guest memory encryptiondrivers/net/ethernet/mellanox/mlx5/core/main.c include/linux/mlx5/driver.h+8 -00 replies
3/23net/mlx5: Add capability filtering in adversarial modedrivers/net/ethernet/mellanox/mlx5/core/Makefile drivers/net/ethernet/mellanox/mlx5/core/caps_filter.c drivers/net/ethernet/mellanox/mlx5/core/main.c +1 more+388 -52 replies
4/23net/mlx5: Add macros for reading log-based capsinclude/linux/mlx5/device.h+20 -00 replies
5/23RDMA/mlx5: Reject QP transport types not enabled by FW capabilitydrivers/infiniband/hw/mlx5/qp.c+11 -20 replies
6/23RDMA/mlx5: Require IB_QPT_DRIVER for the DC vendor QP typesdrivers/infiniband/hw/mlx5/qp.c+10 -61 reply
7/23RDMA/mlx5: Derive mlx5_ib_adversarial_mode global from mlx5_core adversarial APIdrivers/infiniband/hw/mlx5/main.c drivers/infiniband/hw/mlx5/mlx5_ib.h+4 -00 replies
8/23RDMA/core: Suppress kverbs_provider for adversarial_mode devicesdrivers/infiniband/core/device.c include/rdma/ib_verbs.h+10 -02 replies
9/23RDMA/mlx5: Remove duplicate mlx5_ib_umr_context structdrivers/infiniband/hw/mlx5/mlx5_ib.h drivers/infiniband/hw/mlx5/umr.c+2 -80 replies
10/23RDMA/mlx5: Introduce per-CQ poll_one hook in mlx5_ib_cqdrivers/infiniband/hw/mlx5/cq.c drivers/infiniband/hw/mlx5/mlx5_ib.h+10 -10 replies
11/23RDMA/mlx5: Add shadow FIFO infrastructure for UMR completionsdrivers/infiniband/hw/mlx5/mlx5_ib.h drivers/infiniband/hw/mlx5/umr.c drivers/infiniband/hw/mlx5/umr.h+51 -71 reply
12/23RDMA/mlx5: Verify UMR CQ polling against a hostile NICdrivers/infiniband/hw/mlx5/cq.c drivers/infiniband/hw/mlx5/mlx5_ib.h drivers/infiniband/hw/mlx5/umr.c+199 -02 replies
13/23RDMA/mlx5: Keep the UMR QP failed once a forged CQE is detecteddrivers/infiniband/hw/mlx5/umr.c+25 -22 replies
14/23RDMA/mlx5: Block generic CQ poll path in adversarial modedrivers/infiniband/hw/mlx5/cq.c+9 -00 replies
15/23RDMA/core: Set the CQ comp_handler after its poll context is set updrivers/infiniband/core/cq.c+13 -62 replies
16/23RDMA/mlx5: Ignore completion events for a CQ without a handlerdrivers/infiniband/hw/mlx5/cq.c+6 -12 replies
17/23RDMA/mlx5: Validate EQE port and GSI port before indexing devr.ports[]drivers/infiniband/hw/mlx5/gsi.c drivers/infiniband/hw/mlx5/main.c+8 -01 reply
18/23RDMA/mlx5: Validate firmware RQ/SQ state before sqrq_trans[] lookupdrivers/infiniband/hw/mlx5/qp.c+3 -01 reply
19/23RDMA/mlx5: Clamp log_max_cq_sz shift in CQ size checksdrivers/infiniband/hw/mlx5/cq.c+28 -112 replies
20/23RDMA/mlx5: Clamp log_max_* shifts in QP and WQ limit checksdrivers/infiniband/hw/mlx5/qp.c+16 -201 reply
21/23RDMA/mlx5: Clamp log_max_* shifts in query_device and ucontext pathsdrivers/infiniband/hw/mlx5/mad.c drivers/infiniband/hw/mlx5/main.c drivers/infiniband/hw/mlx5/srq.c+35 -322 replies
22/23RDMA/core: Report and enforce adversarial mode via GET_CONTEXTdrivers/infiniband/core/uverbs_cmd.c drivers/infiniband/core/uverbs_std_types_device.c include/uapi/rdma/ib_user_ioctl_cmds.h +1 more+27 -00 replies
23/23RDMA/mlx5: Advertise adversarial mode via ib_device::adversarial_modedrivers/infiniband/hw/mlx5/main.c+1 -01 reply

Reviews trailers per patch

4 of 23 patches have a Reviewed-by or Acked-by.

PatchMoshe ShemeshTariq ToukanYishai Hadas
1/23R-b R-b
2/23R-b
3/23R-b R-b
4/23R-b R-b
5/23
6/23
7/23
8/23
9/23
10/23
11/23
12/23
13/23
14/23
15/23
16/23
17/23
18/23
19/23
20/23
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH rdma-next 00/23] mlx5: Adversarial mode for confidential computing guests

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-4)
- Derive adversarial mode from CC guest memory encryption.
- 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.
- 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 5-8)
- Check the FW capability for every QP transport type, and accept the DC vendor flags only on IB_QPT_DRIVER.
- Keep kernel ULPs off the device by clearing kverbs_provider, so only uverbs binds.

UMR completion verification (patches 9-14)
- 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.
- On a forged CQE, keep the UMR path failed and force the health recovery.
- Refuse the generic CQ poll path, which trusts the CQE.

Validation of FW reported values (patches 15-21)
- Set the CQ completion handler only once its poll context is set up, and ignore completion events for a CQ without one.
- 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 (patches 22-23)
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

Yishai

Dragos Tatulea (2):
net/mlx5: Add capability filtering in adversarial mode net/mlx5: Add macros for reading log-based caps

Yishai Hadas (21):
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/mlx5: Derive mlx5_ib_adversarial_mode global from mlx5_core
adversarial API
RDMA/core: Suppress kverbs_provider for adversarial_mode devices RDMA/mlx5: Remove duplicate mlx5_ib_umr_context struct RDMA/mlx5: Introduce per-CQ poll_one hook in mlx5_ib_cq 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/mlx5: Block generic CQ poll path in adversarial mode RDMA/core: Set the CQ comp_handler after its poll context is set up RDMA/mlx5: Ignore completion events for a CQ without a handler 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 RDMA/mlx5: Advertise adversarial mode via ib_device::adversarial_mode

 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               | 220 +++++++++-
 drivers/infiniband/hw/mlx5/gsi.c              |   4 +
 drivers/infiniband/hw/mlx5/mad.c              |   2 +-
 drivers/infiniband/hw/mlx5/main.c             |  71 ++--
 drivers/infiniband/hw/mlx5/mlx5_ib.h          |  24 +-
 drivers/infiniband/hw/mlx5/qp.c               |  68 ++--
 drivers/infiniband/hw/mlx5/srq.c              |   2 +-
 drivers/infiniband/hw/mlx5/umr.c              | 111 ++++-
 drivers/infiniband/hw/mlx5/umr.h              |   6 +
 .../net/ethernet/mellanox/mlx5/core/Makefile  |   2 +-
 .../ethernet/mellanox/mlx5/core/caps_filter.c | 381 ++++++++++++++++++
 .../net/ethernet/mellanox/mlx5/core/health.c  |  82 +++-
 .../net/ethernet/mellanox/mlx5/core/main.c    |  15 +-
 .../ethernet/mellanox/mlx5/core/mlx5_core.h   |   2 +
 include/linux/mlx5/device.h                   |  20 +
 include/linux/mlx5/driver.h                   |   3 +
 include/rdma/ib_verbs.h                       |   2 +
 include/uapi/rdma/ib_user_ioctl_cmds.h        |   5 +
 include/uapi/rdma/ib_user_ioctl_verbs.h       |   1 +
 23 files changed, 957 insertions(+), 112 deletions(-)
 create mode 100644 drivers/net/ethernet/mellanox/mlx5/core/caps_filter.c
Signature · 1 line
2.18.1