All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Przemek Kitszel" <przemyslaw.kitszel@intel.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH net-next v2 02/14] ice: use shared devlink to store ice_adapters instead of custom xarray
Date: Sat, 10 Oct 2026 12:16:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-166496@kernel.org> (raw)
In-Reply-To: <20261009121433.30347-3-przemyslaw.kitszel@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] ice: DMA UAF due to missing control queue teardown in recovery mode
- [High] ice: NULL pointer deref in ice_adapter_put() on recovery mode teardown
--

commit 298f011950fb287bfb913324af33c969b5683c8d
Author: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: ice: use shared devlink to store ice_adapters instead of custom xarray

This commit refactors the storage and deduplication logic for ice_adapters
by moving it to a shared devlink instance. It replaces the custom xarray
implementation with nested devlink instances for PF devices.

Link: https://lore.kernel.org/all/20260312100407.551173-1-jiri@resnulli.us

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 454fba07d4ecc..6373cd5ac2884 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c

[ ... ]

> @@ -4946,7 +4946,12 @@ static int ice_init_devlink(struct ice_pf *pf)
>  		return err;
>  
>  	ice_devlink_init_regions(pf);
> -	ice_devlink_register(pf);
> +	err = ice_devlink_register(pf);
> +	if (err) {
> +		ice_devlink_destroy_regions(pf);
> +		ice_devlink_unregister_params(pf);
> +		return err;
> +	}

[Severity: High]
Can this new error path lead to a DMA use-after-free regression in recovery
mode?

In ice_probe_recovery_mode(), the hardware control queues are created via
ice_create_all_ctrlq(), which allocates DMA memory using devres. If
ice_init_devlink() fails and returns an error here, the function exits
without calling ice_destroy_all_ctrlq().

The devres framework will unmap and free the DMA memory upon probe failure,
but the hardware ATQ/ARQ registers might still point to those freed
physical addresses since the queues were never gracefully disabled. Could
this allow the active device to continue performing DMA operations on freed
memory?

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.c b/drivers/net/ethernet/intel/ice/ice_adapter.c
> index 2dc3629d6d0f6..c6301341ccaef 100644
> --- a/drivers/net/ethernet/intel/ice/ice_adapter.c
> +++ b/drivers/net/ethernet/intel/ice/ice_adapter.c

[ ... ]

> @@ -93,59 +80,37 @@ static void ice_adapter_free(struct ice_adapter *adapter)

[ ... ]

> -void ice_adapter_put(struct pci_dev *pdev)
> +void ice_adapter_put(struct ice_adapter *adapter)
>  {
> -	struct ice_adapter *adapter;
> -	unsigned long index;
> -
> -	index = ice_adapter_xa_index(pdev);
> -	scoped_guard(mutex, &ice_adapters_mutex) {
> -		adapter = xa_load(&ice_adapters, index);
> -		if (WARN_ON(!adapter))
> -			return;
> -		if (!refcount_dec_and_test(&adapter->refcount))
> -			return;
> -
> -		WARN_ON(xa_erase(&ice_adapters, index) != adapter);
> -	}
> -	ice_adapter_free(adapter);
> +	devlink_shd_put(adapter->devlink);
>  }

[Severity: High]
Will this trigger a NULL pointer dereference regression if the driver is
probed in recovery mode?

If the driver probes in recovery mode, pf->adapter is never allocated and
remains NULL. During ice_remove(), the code checks
ice_is_recovery_mode(&pf->hw) to determine if it should perform a
recovery-mode early return or a full teardown.

Since ice_is_recovery_mode() reads a live volatile hardware register, if
the firmware clears this bit after probe, the check bypasses the early
return and falls through to normal teardown:

drivers/net/ethernet/intel/ice/ice_main.c:ice_remove() {
    ...
    ice_adapter_put(pf->adapter);
    ice_deinit_hw(&pf->hw);
    ...
}

The previous xarray lookup safely returned early on NULL, but the new code
unconditionally dereferences adapter->devlink. Will this crash on driver
unload or device unbind when transitioning out of recovery mode?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261009121433.30347-1-przemyslaw.kitszel@intel.com?part=2

  reply	other threads:[~2026-10-10 12:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 12:04 [PATCH net-next v2 00/14] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 01/14] devlink, mlx5: add init/fini ops for shared devlink Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 02/14] ice: use shared devlink to store ice_adapters instead of custom xarray Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot [this message]
2026-10-13 12:57     ` Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 03/14] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 04/14] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 05/14] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 06/14] ice: bump to 256qs for VF Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot
2026-10-13 13:46     ` Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 07/14] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 08/14] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot
2026-10-13 13:27     ` Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 09/14] iavf: increase max number of queues to 256 Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 10/14] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot
2026-10-09 12:04 ` [PATCH net-next v2 11/14] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 12/14] devlink: give user option to allocate resources Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 13/14] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot
2026-10-13 13:49     ` Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 14/14] ice: support up to 256 VF queues Przemek Kitszel
2026-10-10 12:16   ` sashiko-bot

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-166496@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=przemyslaw.kitszel@intel.com \
    --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.