🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
2 messages
2 total messages Started by Minseok Kim Thu, 26 Nov 2026 06:44
[PATCH iwl-net] ice: bound the node count in ice_sched_add_elems()
#22929
Author: Minseok Kim
Date: Thu, 26 Nov 2026 06:44
101 lines
14970 bytes
ice_sched_add_node() appends to the parent's child array without
checking that there is room:

	parent->children[parent->num_children++] = node;

That array is allocated in the same function with exactly
hw->max_children[layer] entries and is a separate allocation from the
node itself, so a write past its end lands in unrelated memory.
Neither ice_sched_add_node() nor ice_sched_add_elems(), which drives it
in a loop, bounds num_children.

The bound is enforced one level further out instead, in
ice_sched_add_nodes_to_hw_layer():

	if ((parent->num_children + num_nodes) > max_child_nodes) {

ice_devlink_set_parent() does not go through that wrapper. It calls
ice_sched_add_elems() directly to create a node for a devlink rate
object, and has no equivalent check of its own, so re-parenting rate
objects onto one node is only limited by how many children the
firmware is willing to create.

Bound the request in ice_sched_add_elems() rather than at the call
site, so that both callers and any later one are covered. The check
sits before ice_aq_add_sched_elems(), so a rejected request leaves no
hardware state behind, and it returns -ENOSPC, which
ice_sched_add_nodes_to_layer() already treats as "this parent is full"
when it retries on a sibling.

The existing check in ice_sched_add_nodes_to_hw_layer() is left alone.
It returns -EIO instead of -ENOSPC when the full parent is the TC node,
and that distinction is caller policy rather than something the callee
can reconstruct.

Both callers of ice_sched_add_elems(), ice_cfg_vsi_qs() by way of
ice_sched_add_nodes_to_hw_layer() and ice_devlink_set_parent(), hold
pi->sched_lock, so reading parent->num_children here is serialised
against the rest of the tree.

Fixes: 42c2eb6b1f43 ("ice: Implement devlink-rate API")
Signed-off-by: Minseok Kim <kor8821@gmail.com>
---
Found by code audit of the two call sites of ice_sched_add_elems().

Notes on testing and tool assistance (per
Documentation/process/generated-content.rst):

- Tool assistance: Claude Code (Anthropic) was used during static source
  auditing of the two ice_sched_add_elems() call sites, to draft the
  commit description and the bounds check, and to run the build and
  style checks.  All findings, the code change and the commit text were
  independently verified and edited by the author, who takes full
  responsibility for the patch.

- Testing: compile-tested only, on x86_64 (defconfig + CONFIG_PCI_IOV +
  CONFIG_DCB + CONFIG_ICE) with `make W=1
  drivers/net/ethernet/intel/ice/` against a baseline build of the same
  tree: 0 warnings and 0 errors before and after, with an empty diff
  between the two logs.  scripts/checkpatch.pl --strict reports 0
  errors, 0 warnings, 0 checks.  No runtime testing was done: I have no
  E800-series hardware, so the capacity path was not exercised, and the
  behaviour change should be treated as untested on silicon.

- Not Cc'd to stable: I have not shown that an over-capacity request is
  reachable in practice, since hw->max_children[] is itself firmware
  reported and the firmware may refuse the extra child first.  This is
  offered as making the two callers of ice_sched_add_elems() consistent
  with each other, not as a fix for an observed overflow.  If you would
  rather rely on the firmware here and drop it, that is a fair answer.

A separate patch to the same function is on the list, "ice: Do not free
a preallocated node in ice_sched_add_node()", Message-ID
<20261119055731.55798-1-izaiahsun@gmail.com>.  The two touch different
hunks and should not conflict, but they may want ordering.
 drivers/net/ethernet/intel/ice/ice_sched.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
index a5c7a4e1c..ae4528347 100644
--- a/drivers/net/ethernet/intel/ice/ice_sched.c
+++ b/drivers/net/ethernet/intel/ice/ice_sched.c
@@ -909,6 +909,14 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
 	int status = 0;
 	u32 teid;
 
+	/* parent->children[] holds hw->max_children[] entries for the parent's
+	 * layer and ice_sched_add_node() appends to it unconditionally, so the
+	 * request has to be bounded before any node is created.
+	 */
+	if (parent->num_children + num_nodes >
+	    hw->max_children[parent->tx_sched_layer])
+		return -ENOSPC;
+
 	buf_size = struct_size(buf, generic, num_nodes);
 	buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
 	if (!buf)

base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
-- 
2.34.1
Re: [PATCH iwl-net] ice: bound the node count in ice_sched_add_elems()
#23736
Author: Przemek Kitszel
Date: Fri, 27 Nov 2026 21:15
33 lines
20697 bytes
> diff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c
> index a5c7a4e1c..ae4528347 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sched.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sched.c
> @@ -909,6 +909,14 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
>   	int status = 0;
>   	u32 teid;
>   
> +	/* parent->children[] holds hw->max_children[] entries for the parent's
> +	 * layer and ice_sched_add_node() appends to it unconditionally, so the
> +	 * request has to be bounded before any node is created.
> +	 */

we have to trust FW, I would rather do nothing than add such prevention
--

side note: I was working on a OOT bug that manifested in crash a couple
lines down from here - FW was returning 0 as number of children after
a change to 5 layer topology from 9 layer

a fix was to properly re-ask for current topology during the vsi rebuild

> +	if (parent->num_children + num_nodes >
> +	    hw->max_children[parent->tx_sched_layer])
> +		return -ENOSPC;
> +
>   	buf_size = struct_size(buf, generic, num_nodes);
>   	buf = devm_kzalloc(ice_hw_to_dev(hw), buf_size, GFP_KERNEL);
>   	if (!buf)
> 
> base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads