All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stefan Metzmacher" <metze@samba.org>
Cc: intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] ice: support the enable_rdma devlink param in runtime cmode
Date: Tue, 01 Dec 2026 22:10:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-244322@kernel.org> (raw)
In-Reply-To: <04b80a45d0b1544b0b32e9ee72223f09005fa51c.1796076486.git.metze@samba.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ice: race between ice_devlink_enable_rdma_set() and
  concurrent plug or reset
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] ice: NULL pointer dereference in
  ice_devlink_enable_iw_validate() [1]
--

commit 5131a328af0137c04875bae323e3ebe30dcdfd51
Author: Stefan Metzmacher <metze@samba.org>

ice: support the enable_rdma devlink param in runtime cmode

This commit adds runtime configuration mode support for the enable_rdma
devlink parameter so the RDMA auxiliary device can be plugged or unplugged
without reloading the PF netdev.

> diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c
> index 5a69f0f8a7bc4..8d816631df69f 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c
[ ... ]
> @@ -1626,6 +1629,62 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id,
[ ... ]
> +static int ice_devlink_enable_rdma_set(struct devlink *devlink, u32 id,
> +				       struct devlink_param_gset_ctx *ctx,
> +				       struct netlink_ext_ack *extack)
> +{
> +	struct ice_pf *pf = devlink_priv(devlink);
> +	bool disable = !ctx->val.vbool;
> +	int ret;
> +
> +	if (!disable && !ice_is_rdma_ena(pf)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "RDMA is disabled in driverinit cmode, enable it there and reload");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	if (test_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags) == disable)
> +		return 0;
> +
> +	if (disable) {
> +		set_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags);
> +		ice_unplug_aux_dev(pf);
> +		return 0;
> +	}
> +
> +	if (!pf->cdev_info || !pf->cdev_info->rdma_protocol) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Neither enable_roce nor enable_iwarp is set");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	clear_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags);
> +	ret = ice_plug_aux_dev(pf);
> +	if (ret)
> +		set_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags);
> +
> +	return ret;
> +}

[Severity: Medium]
Can ice_devlink_enable_rdma_set() race with ice_plug_aux_dev() or a PF
reset running on pf->serv_task?

ice_devlink_enable_rdma_set() runs under devl_lock(devlink), while
ice_service_task() and PF reset/rebuild call ice_plug_aux_dev() and
ice_unplug_aux_dev() without holding devl_lock(devlink), and
pf->adev_mutex only covers the cdev->adev assignment:

CPU0                                     CPU1 (pf->serv_task)
                                         ice_plug_aux_dev()
                                           test_bit(ICE_FLAG_RDMA_RUNTIME_DIS,
                                                    ...) -> 0
                                           ...
ice_devlink_enable_rdma_set()
  set_bit(ICE_FLAG_RDMA_RUNTIME_DIS,
          ...)
  ice_unplug_aux_dev()
    test_and_clear_bit(
      ICE_FLAG_AUX_DEV_CREATED, ...)
      -> 0 (returns early)
                                           auxiliary_device_add(adev)
                                           set_bit(ICE_FLAG_AUX_DEV_CREATED,
                                                   ...)
                                             <-- aux dev stays plugged

The auxiliary device remains registered while ICE_FLAG_RDMA_RUNTIME_DIS is
set and ice_devlink_enable_rdma_get() reports false.  In addition, if
ice_devlink_enable_rdma_set() enables RDMA while a PF reset is in progress
between ice_prepare_for_reset() and ice_rebuild(), it plugs the auxiliary
device mid-reset and ice_rebuild() -> ice_rdma_finalize_setup() then calls
ice_plug_aux_dev() a second time.

> @@ -1654,8 +1713,11 @@ static const struct devlink_param ice_dvl_rdma_params[] = {
>  			      ice_devlink_enable_iw_get,
>  			      ice_devlink_enable_iw_set,
>  			      ice_devlink_enable_iw_validate),
> -	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
> -			      NULL, NULL, ice_devlink_enable_rdma_validate),
> +	DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT) |
> +			      BIT(DEVLINK_PARAM_CMODE_RUNTIME),
> +			      ice_devlink_enable_rdma_get,
> +			      ice_devlink_enable_rdma_set,
> +			      ice_devlink_enable_rdma_validate),
>  };

[Severity: High]
This problem wasn't introduced by this patch, but can
ice_devlink_enable_iw_validate() [1] trigger a NULL pointer
dereference on pf->cdev_info when enable_rdma is false in driverinit
cmode?

When enable_rdma is disabled in driverinit cmode and the PF is reloaded,
ice_deinit_rdma() frees and clears pf->cdev_info, ice_set_pf_caps() still
sets ICE_FLAG_RDMA_ENA, and ice_init_rdma() returns early because
ice_is_rdma_ena() is false.  Unlike ice_devlink_enable_rdma_set() and
ice_devlink_enable_roce_validate(), ice_devlink_enable_iw_validate() only
checks ICE_FLAG_RDMA_ENA before dereferencing pf->cdev_info:

drivers/net/ethernet/intel/ice/devlink/devlink.c:ice_devlink_enable_iw_validate() {
	struct ice_pf *pf = devlink_priv(devlink);

	if (!test_bit(ICE_FLAG_RDMA_ENA, pf->flags))
		return -EOPNOTSUPP;

	if (pf->cdev_info->rdma_protocol & IIDC_RDMA_PROTOCOL_ROCEV2) {
    ...
}

Setting enable_iwarp in that state dereferences a NULL pf->cdev_info.

[1] https://sashiko.dev/#/bug/linux-aab1240e-86ed-43b4-be4c-d5891c480f23

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796076486.git.metze@samba.org?part=3

      parent reply	other threads:[~2026-12-01 22:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 22:09 [PATCH net-next 0/3] devlink: support the enable_rdma param in runtime cmode for cxgb4, mlx5 and ice Stefan Metzmacher
2026-11-30 22:09 ` [PATCH net-next 1/3] cxgb4: support the enable_rdma devlink param in runtime cmode Stefan Metzmacher
2026-12-01 22:10   ` sashiko-bot
2026-11-30 22:09 ` [PATCH net-next 2/3] net/mlx5: " Stefan Metzmacher
2026-12-01 22:10   ` sashiko-bot
2026-11-30 22:10 ` [PATCH net-next 3/3] ice: " Stefan Metzmacher
2026-12-01 13:36   ` Przemek Kitszel
2026-12-01 22:10   ` sashiko-bot [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=sashiko-outbox-244322@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.