From: Minseok Kim <kor8821@gmail.com>
To: intel-wired-lan@lists.osuosl.org
Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com,
przemyslaw.kitszel@intel.com, m.wilczynski@samsung.com
Subject: [PATCH iwl-net] ice: bound the node count in ice_sched_add_elems()
Date: Thu, 26 Nov 2026 15:44:02 +0900 [thread overview]
Message-ID: <20261126064402.87229-1-kor8821@gmail.com> (raw)
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
reply other threads:[~2026-11-26 6:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261126064402.87229-1-kor8821@gmail.com \
--to=kor8821@gmail.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=m.wilczynski@samsung.com \
--cc=netdev@vger.kernel.org \
--cc=przemyslaw.kitszel@intel.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