Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yishai Hadas <yishaih@nvidia.com>
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
Date: Sun, 29 Nov 2026 14:58:23 +0200	[thread overview]
Message-ID: <20261129125823.GH774860@unreal> (raw)
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
> 

      parent reply	other threads:[~2026-11-29 12:58 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 17:08 [PATCH V2 rdma-next 00/21] mlx5: Adversarial mode for confidential computing guests Yishai Hadas
2026-11-17 17:08 ` [PATCH V2 rdma-next 01/21] net/mlx5: Add mlx5_trigger_health_work_force() Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-19  8:06     ` Yishai Hadas
2026-11-17 17:08 ` [PATCH V2 rdma-next 02/21] net/mlx5: Derive adversarial mode from CC guest memory encryption Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:08 ` [PATCH V2 rdma-next 03/21] net/mlx5: Add capability filtering in adversarial mode Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:08 ` [PATCH V2 rdma-next 04/21] net/mlx5: Catch too low max number of EQs Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-19  7:47     ` Yishai Hadas
2026-11-17 17:08 ` [PATCH V2 rdma-next 05/21] net/mlx5: Add macros for reading log-based caps Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:08 ` [PATCH V2 rdma-next 06/21] RDMA/mlx5: Reject QP transport types not enabled by FW capability Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 07/21] RDMA/mlx5: Require IB_QPT_DRIVER for the DC vendor QP types Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 08/21] RDMA/core: Suppress kverbs_provider for adversarial_mode devices Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 09/21] RDMA/mlx5: Set ib_device::adversarial_mode from mlx5_core Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 10/21] RDMA/mlx5: Remove duplicate mlx5_ib_umr_context struct Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 11/21] RDMA/mlx5: Add shadow FIFO infrastructure for UMR completions Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 12/21] RDMA/mlx5: Verify UMR CQ polling against a hostile NIC Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-19 10:17     ` Yishai Hadas
2026-11-17 17:09 ` [PATCH V2 rdma-next 13/21] RDMA/mlx5: Keep the UMR QP failed once a forged CQE is detected Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 14/21] RDMA/core: Set the CQ comp_handler after its poll context is set up Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 15/21] RDMA/mlx5: Ignore completion events for a kernel CQ that is not ready Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 16/21] RDMA/mlx5: Validate EQE port and GSI port before indexing devr.ports[] Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 17/21] RDMA/mlx5: Validate firmware RQ/SQ state before sqrq_trans[] lookup Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-19 10:47     ` Yishai Hadas
2026-11-17 17:09 ` [PATCH V2 rdma-next 18/21] RDMA/mlx5: Clamp log_max_cq_sz shift in CQ size checks Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 19/21] RDMA/mlx5: Clamp log_max_* shifts in QP and WQ limit checks Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 20/21] RDMA/mlx5: Clamp log_max_* shifts in query_device and ucontext paths Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-17 17:09 ` [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT Yishai Hadas
2026-11-18 17:13   ` sashiko-bot
2026-11-22  7:31   ` Leon Romanovsky
2026-11-22  9:33     ` Yishai Hadas
2026-11-24 12:53       ` Leon Romanovsky
2026-11-24 12:59         ` Jason Gunthorpe
2026-11-24 13:33           ` Leon Romanovsky
2026-11-24 13:47             ` Jason Gunthorpe
2026-11-24 14:09               ` Leon Romanovsky
2026-11-24 14:30                 ` Jason Gunthorpe
2026-11-25  9:03                   ` Leon Romanovsky
2026-11-25 11:41                     ` Yishai Hadas
2026-11-26 14:12                       ` Leon Romanovsky
2026-11-26 15:57                       ` Leon Romanovsky
2026-11-29  8:00                         ` Yishai Hadas
2026-11-25 14:45                     ` Jason Gunthorpe
2026-11-26 14:05                       ` Leon Romanovsky
2026-11-26 15:17                         ` Jason Gunthorpe
2026-11-29 12:58 ` Leon Romanovsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261129125823.GH774860@unreal \
    --to=leon@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@nvidia.com \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=yishaih@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox