Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linkui Xiao" <xiaolinkui@126.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH iwl-net] ice: wait for in-flight Rx polls before freeing a representor
Date: Tue, 13 Oct 2026 07:31:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-169189@kernel.org> (raw)
In-Reply-To: <20261012072959.254206-1-xiaolinkui@126.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ice: UAF in RX path due to premature rcu_read_unlock and shared NAPI
--

commit 85b479dcdaa34d1d1340c09f178fce9d7d04ceda
Author: Linkui Xiao <xiaolinkui@kylinos.cn>

ice: wait for in-flight Rx polls before freeing a representor

This commit adds an explicit RCU read-side critical section in the Rx path
when looking up a representor netdev. It also adds a synchronize_net() call
in the detach path to wait for the Rx path to complete before tearing down
the representor.

> diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> index c32d6b201369b..0e5b98a05981d 100644
> --- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
> @@ -566,6 +566,13 @@ static void ice_eswitch_detach(struct ice_pf *pf, struct ice_repr *repr)
>  
>  	xa_erase(&pf->eswitch.reprs, repr->id);
>  
> +	/* The Rx path looks the representor up by its id and dereferences the
> +	 * result without holding a reference to it. Nothing can find it in the
> +	 * xarray anymore, so wait for the polls that picked it up before the
> +	 * erase to finish before the representor is torn down.
> +	 */
> +	synchronize_net();
> +

[Severity: High]
Does this synchronize_net() return too early?

Since the explicitly added RCU read lock is dropped in
ice_process_skb_fields(), the packet is passed to napi_gro_receive()
outside of the RCU critical section:

ice_clean_rx_irq()
  ice_process_skb_fields()
    rcu_read_unlock()
  napi_gro_receive()

This means the packet can be queued in the uplink VSI's NAPI GRO hash.

Because the representor shares the uplink VSI's NAPI, unregistering the
representor will not flush this GRO hash.

Could synchronize_net() return while the packet is still held in the uplink
VSI's GRO hash because the RCU lock was already dropped, leading to the
premature freeing of the representor netdev?

>  	if (xa_empty(&pf->eswitch.reprs))
>  		ice_eswitch_disable_switchdev(pf);

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> index 19307086c238f..e0712db9273cd 100644
> --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
> @@ -235,6 +243,7 @@ ice_process_skb_fields(struct ice_rx_ring *rx_ring,
>  		 */
>  		__skb_push(skb, ETH_HLEN);
>  		skb->protocol = eth_type_trans(skb, netdev);
> +		rcu_read_unlock();

[Severity: High]
Is it safe to drop the explicitly added RCU read lock here?

It seems this leaves skb->dev unprotected from being freed while the
packet is still being processed and passed up the stack in
ice_clean_rx_irq(). Should the lock be held longer to ensure the packet
safely traverses the stack or gets flushed from the GRO hash?

>  	}
>  
>  	ice_rx_csum(rx_ring, skb, rx_desc, ptype);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012072959.254206-1-xiaolinkui@126.com?part=1

      parent reply	other threads:[~2026-10-13  7:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12  7:29 [PATCH iwl-net] ice: wait for in-flight Rx polls before freeing a representor Linkui Xiao
2026-10-12  7:34 ` netdev-bot+sinfo
2026-10-12  8:35   ` Linkui Xiao
2026-10-13  7:31 ` 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-169189@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaolinkui@126.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