🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26728

Re: [PATCH net v3 2/2] ice: clear Flow Director entries before reset cleanup

#26728
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 04:27
208 lines
15295 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] If ice_flow_add_prof() fails in ice_fdir_replay_flows(), the
  new error path only logs and continues.
- [Low] The commit message understates the VF half of the use-after-free.
- [Low] The patch makes ice_vsi_manage_fdir() return int and adds kernel-
  doc saying 'Return: 0 on success, negative errno on failure.' The…

--

ice: clear Flow Director entries before reset cleanup

Before ice_clear_hw_tbls() runs during reset, this patch frees the VF
Flow Director profiles and invalidates the PF Flow Director entry handles
and profile IDs. It also serializes PF Flow Director updates, reset
cleanup and replay with hw->fdir_fltr_lock, and checks the return value
of ice_flow_add_prof() during replay.

> PF and VF Flow Director profiles keep handles to flow entries freed by
> ice_clear_hw_tbls() during reset. If PF rebuild fails during system
> resume before replay replaces them, driver unload dereferences a freed
> entry:

[ ... ]

> By code inspection, VF Flow Director profiles are not replayed across
> reset, and ice_fdir_replay_flows() uses hw_prof without checking
> ice_flow_add_prof().

[Severity: Low]
Does this understate the VF side of the use-after-free? Before this
patch, the VF part did not seem to need a rebuild failure, a resume or a
driver unload. Any PFR, CORER, GLOBR or EMPR reset with VF Flow Director
rules installed looks like enough to trigger it:

ice_prepare_for_reset()
  ice_clear_hw_tbls()
    ice_free_flow_profs()
      frees every ice_flow_prof and ice_flow_entry on
      hw->fl_profs[ICE_BLK_FD], including the entries referenced by
      vf->fdir.fdir_prof[flow]->entry_h[][]

ice_do_reset() or ice_reset_subtask()
  ice_rebuild()
  ice_reset_all_vfs()
    ice_vf_fdir_exit()
      ice_vc_fdir_rem_prof_all()
        ice_vc_fdir_rem_prof()
          ice_flow_rem_entry(hw, ICE_BLK_FD, vf_prof->entry_h[i][tun])

ice_flow_rem_entry() then reads entry->prof from the freed entry. It
also calls list_del() and devm_kfree() on it a second time.

The new ice_vc_fdir_free_prof_all() call in ice_prepare_for_reset() is
what fixes this common path. The message presents it as an extra found
by code inspection.

Could the commit message describe the VF trigger? Would a Fixes: tag for
the commit that added VF Flow Director support also make sense? The
current tag only points at the PF Flow Director init commit.

> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c b/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c
> index 8805f0efe9773..38d7aea103ee6 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool_ntuple.c

[ ... ]

> @@ -431,16 +453,25 @@ void ice_fdir_replay_flows(struct ice_hw *hw)
>  		for (tun = 0; tun < ICE_FD_HW_SEG_MAX; tun++) {
>  			struct ice_flow_prof *hw_prof;
>  			struct ice_fd_hw_prof *prof;
> -			int j;
> +			int err, j;
>  
>  			prof = hw->fdir_prof[flow];
> -			ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX,
> -					  prof->fdir_seg[tun], TNL_SEG_CNT(tun),
> -					  false, &hw_prof);
> +			if (!prof->fdir_seg[tun])
> +				continue;
> +
> +			err = ice_flow_add_prof(hw, ICE_BLK_FD, ICE_FLOW_RX,
> +						prof->fdir_seg[tun],
> +						TNL_SEG_CNT(tun), false,
> +						&hw_prof);
> +			if (err) {
> +				dev_err(ice_hw_to_dev(hw), "Could not replay Flow Director, flow type %d\n",
> +					flow);
> +				continue;
> +			}

[Severity: Medium]
If ice_flow_add_prof() fails here, can the Flow Director state for this
flow get stuck? For example, ice_flow_add_prof_sync() can return -ENOSPC
or -ENOMEM.

ice_fdir_clear_flow_handles() zeroed entry_h[] and set prof_id[] to all
0xff. It left prof->fdir_seg[tun] and prof->cnt unchanged. After this
continue, software still holds a segment for a profile that no longer
exists in hardware.

A later ethtool -N with the same input set goes through:

ice_add_ntuple_ethtool()
  ice_cfg_fdir_xtrct_seq()
    ice_fdir_set_hw_fltr_rule()

That function finds the leftover segment:

ice_fdir_set_hw_fltr_rule() {
    ...
	old_seg = hw_prof->fdir_seg[tun];
	if (old_seg) {
		...
		if (!memcmp(old_seg, seg, sizeof(*seg)))
			return -EEXIST;
    ...
}

ice_cfg_fdir_xtrct_seq() then turns that into success:

	if (ret == -EEXIST) {
		/* Rule already exists, free memory and count as success */
		ret = 0;

The filter is added to the SW list and programmed through the control
VSI. However, no HW flow profile or entry backs it for this flow type,
so it would never match. Filters that ice_fdir_replay_fltrs() replays
for that flow seem to end up the same way.

Nothing appears to re-create the profile until the input set changes,
which is only allowed once fdir_fltr_cnt[flow] is 0, or until ntuple is
turned off and on again.

The ice_flow_add_entry() failure branch later in this loop seems to have
the same problem. Both are an improvement over the old code, which used
an uninitialized hw_prof.

Would clearing prof->fdir_seg[tun], or calling ice_fdir_rem_flow() for
this flow on replay failure, let a later add re-create the profile?

[ ... ]

> @@ -1636,20 +1666,27 @@ void ice_fdir_del_all_fltrs(struct ice_vsi *vsi)
>   * ice_vsi_manage_fdir - turn on/off flow director
>   * @vsi: the VSI being changed
>   * @ena: boolean value indicating if this is an enable or disable request
> + *
> + * Return: 0 on success, negative errno on failure.
>   */
> -void ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena)
> +int ice_vsi_manage_fdir(struct ice_vsi *vsi, bool ena)
>  {
>  	struct ice_pf *pf = vsi->back;
>  	struct ice_hw *hw = &pf->hw;
>  	enum ice_fltr_ptype flow;
> +	int ret = 0;
>  
> +	mutex_lock(&hw->fdir_fltr_lock);
>  	if (ena) {
> +		if (ice_is_reset_in_progress(pf->state)) {
> +			ret = -EBUSY;
> +			goto release_lock;
> +		}
>  		set_bit(ICE_FLAG_FD_ENA, pf->flags);
>  		ice_fdir_create_dflt_rules(pf);
> -		return;
> +		goto release_lock;
>  	}

[Severity: Low]
The new kernel-doc says this returns a negative errno on failure. Should
the result of ice_fdir_create_dflt_rules() be passed back here?

Through ice_create_init_fdir_rule(), ice_fdir_create_dflt_rules() can
fail with -EOPNOTSUPP, -ENOMEM or -EINVAL. ice_init_fdir() treats that
failure as fatal and calls ice_fdir_release_flows().

In this branch ret stays 0, so on enable the only error ice_set_features()
can see is -EBUSY:

ice_set_features() {
    ...
		ret = ice_vsi_manage_fdir(vsi, ena);
		if (ret)
			return ret;
		ena ? ice_init_arfs(vsi) : ice_clear_arfs(vsi);
    ...
}

A failed default rule setup therefore looks like success, with
ICE_FLAG_FD_ENA set and profiles only partly created. The runtime
behavior is the same as the old void version. The documented return
contract now says otherwise, though.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203035320.187412-1-aaron.ma%40canonical.com
Technical Details
Message-ID: <179635843579.3146.11258874149190474073@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377053-linux-kernel-netdev=dewy.ru
References: <20261203035320.187412-2-aaron.ma@canonical.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377053-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/2] ice: clear Flow Director entries before reset cleanup
Date: Fri, 04 Dec 2026 04:27:15 +0000
Organization: Usenet Network
Message-ID: <179635843579.3146.11258874149190474073@kernel.org>
References: <20261203035320.187412-2-aaron.ma@canonical.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2673897"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+rmZBZtinK9rhGpyCfkgrs/CRS0= sha256:Qa2MeEDRSnEKIYxJdnPqEqKyTeAJI/ZKkiPX6GBoom4=
	sha1:fDYnre9O/R2Ds+m6MvOeaKC+SD0= sha256:uooiIC2bYDUG4oGZ5HRTbad1aDt4S/osQ+92ASQC3fI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D31C5117AF9; Fri,  4 Dec 2026 07:27:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id SSGq4aml1erf;
	Fri,  4 Dec 2026 07:27:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377053-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id AFF5B117AFA; Fri,  4 Dec 2026 07:27:26 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 1D66626B20; Fri,  4 Dec 2026 04:27:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796358437;
	b=O0a/Hx/uIISTPrc4zmoY/FFBOGtExJTmkN4aG+IKCfONVeJ4zK2cxKmO5CMBXd17A5+F
	 I40doIAUEtZ1NUHMUkxdQd/6IV8tIYiIAKTlsLlXZBvXiTgojEUNKsnPgePtKdlVDUeX/
	 7C4FyJlNc/ijb3VZWwlM+y2N3DJZzpSY4bikD+PPcQaG+K7A2V96hNLGSjBdGWtdF02x0
	 PuTJGxLzLHDJuKDpjzqyCoEW6QhhmSr1yeqr9jCW/Z2NueEnVoIXFXaWzw6n2Iq/ZoOVk
	 WrUk16KHUyQS/lA30JqXTSerYxvhSwftm30e0vSDUuUHU6VGrqul7pNaz8bEp7NgFRw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796358437;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=DQGCnZtdX/N9ie2JgKvLr6jcgQeezwpBp88i6vQZMKw=;
	b=2xk3S8Rx0IFXAujAId+luYy4y+WogIrShSQD4dk2KpFRssa1GHPBvDvqbfGT/B32mrb/
	 E+fE3s3EjWe6rnafSZLKbjE/5PZJEpKq7JnGO+rTucX/k9v7+gXB0wS1umUMAKbYp9qTn
	 bz8969OSkpfShPr/3IK2AA11L9RixLVD6F7/3h4TNHGKNhkozdZ9e6cK6DUTWiSTtRb0y
	 qOuc9e7ZCZhild2zh8QU61V0DqBIQNU/HxyS5Hthg68/5JYeux9LBHh1cfmRFB06OBI18
	 zL2HQ4x36a61S3hSpabNGJgsvR7Vxi6I1CG4MKURNtq+s8YJwOk6qNAMRuvQ0Ty5N2g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jVu10RPq;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id D1FB4606A339;
	Fri,  4 Dec 2026 04:27:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jVu10RPq
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796358437;
	b=Zh5ouhcr1v9j6JDkS+Rqo+nwsVWvWuPjRqtoknnT83Q8HrIxpi/AQMRmob8yYRh/rnFt
	 cbIWNAYNhPUxeYU7phLrNuCltaeuH+OpeVMHF0ZWIfKrrl2Gf/r0xkDqtEKVDPjxlNzrq
	 krATv9AkPDL5yTMfzRw85QMp1KoEFeRaXieEpHnvBv5JYNiGzsmvg/tXPzkn2cqvmv6Re
	 aX+8U0ji/awBmP8aTQwKGPLhQPx/z8BgZOtUt3q/7wyrzJw6hJxFJTYiEkNUb67I3iNDC
	 dLdDb8Vnu1yQUZboQACqzPIQIcRNO0fRbWi2hY+QvA/xWOCoK3VFJdzpD5TsKlWiADw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796358437;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=DQGCnZtdX/N9ie2JgKvLr6jcgQeezwpBp88i6vQZMKw=;
	b=1VXXoD213t/bJKYMFvmwfRzw4IqxQ4axxrcHgkotMLzOqHcmAdZaG/uiJBzdKm94tn34
	 h12bPT1u2746Ld9T+dlcc5wEodaEUuxsYPyTX7JDSf7ySamYZCzEZX4P+fzYW2OW+N9CJ
	 I0bJFPbkA+UMEZ83C+CluvPYNMsetPG6OCRcEz/MOoV5ziqNmc3pAPN7xTgoxltg3oWSp
	 wTIcsU0TjOosr9mvSIk/EOoL5JV8LbGURYoV4vObrGLPn5DZ+EwwQ1HPN2VrTYKQ5bViC
	 0JX11c+mxjUnBs/K96rlXveWDgy3akyUBoiaNPqPGqUGcjfRxpdiT4Cv/hNvQo65UgA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jVu10RPq;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3DEC606A337
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 04:27:16 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39BB21F00933;
	Fri,  4 Dec 2026 04:27:16 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796358436;
	bh=DQGCnZtdX/N9ie2JgKvLr6jcgQeezwpBp88i6vQZMKw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=jVu10RPqP8gBPBxPhjHeJQmCBnxzY3P5OKqYb/pvfCU2jv6B+W1/19aqJwMBBPRjY
	 bwWERpb+BZQG2bqy63ugauu6M3FcrlrPQAilOR1iQBzGZYHkn9IgG+df1h2dl6VQ3T
	 oQpOdgIDCIfduFaaPKIwA8hZKYs3VO5FknmemHRlEk8IkZ1PzkNPGtgZv7hkMhbwmR
	 mV1Po+7HjMgDC9Hi1EjZ0ize/FiV9xzhn4pJwBIhoDYZ0vdFrJVGXV6yHYMLYO/wO6
	 /2su+OqKDADvCXZ+OG9D3NloFZPJWJaWimI/tXpH98m/6mFP2Jqz1BZeKRo1rCKdRA
	 2N/tKnMF9fQ1Q==
X-Cc: anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com,
 andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
 henry.w.tieman@intel.com, intel-wired-lan@lists.osuosl.org
X-In-Reply-To: <20261203035320.187412-2-aaron.ma@canonical.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list