Article View: linux.kernel.netdev
Article #22929[PATCH iwl-net] ice: bound the node count in ice_sched_add_elems()
From: Minseok Kim
Date: Thu, 26 Nov 2026 06:44
Date: Thu, 26 Nov 2026 06:44
101 lines
14970 bytes
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
Technical Details
Message-ID:
<20261126064402.87229-1-kor8821@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371912-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371912-linux-kernel-netdev=dewy.ru
From: kor8821@gmail.com (Minseok Kim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH iwl-net] ice: bound the node count in ice_sched_add_elems()
Date: Thu, 26 Nov 2026 15:44:02 +0900
Organization: Usenet Network
Message-ID: <20261126064402.87229-1-kor8821@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="401057"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Gb/h0z8I1Gx3pF8TkZxc/y0D8xA= sha256:KVerHeb9OeiC0hyaXrYPWXTf8/IaxB17UeudSdtvFIA=
sha1:XqFtVCmV2oFkF++CBtNNDSgU6Dw= sha256:VSnPPaRhetDfx9hdS2oIWoAQ3ai239upLTCqImH4uGw=
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 8E9C7125EB2; Thu, 26 Nov 2026 09:44:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 WMXJQGIbnBYl;
Thu, 26 Nov 2026 09:44:20 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371912-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 67E27125EB0; Thu, 26 Nov 2026 09:44:12 +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 E580643346; Thu, 26 Nov 2026 06:44:08 +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=1795675448;
b=qLcUWvZPcQaggwPtqNVBO1p7+OLPn8YGYf3nVAN7t5dTc9QXe63Su8S7dDswsg+l6RRf
pGpWdTxlJpxfRbO5Q19lobpOIAmqEpGDEdYm2TkSwvz0XVmXEIzVDsc+ZY03mnDcluRf2
nYyWlTq+ntlO3Lr4w2fndClVE760xis/JBm6wNbOH/sailCXdjE5mU/qHxIkco2IFVrMh
uHNtiqg1JDiBVy56oN/kRGNenPHViCg8bAv/2LTN640fYLNhqhUFe5plIepqStMhGeShx
m0O5jJOTl1W5QOjlUZhaqUOsP7htWyPXDvnWdGChr5tMxrB/aC9QJBqiSlK1m0eloFA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795675448;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
bh=IGOZXvHj7Kp3VoWvYB9VXQ2RIbnpFsMHzOt42EfzF7E=;
b=dlKfqOQVNeA/SJVnvPT7UAk3bw7ZR3XelTM+1VVZDSb2wika29xdW4U3utahvUgpdADV
ftOOLWcc0P4NG8sMArBsa4rKrLxtMPfrTKa2eC5s0lqaMOZScffNxr5KDpqF2OfH31/cs
1UKOoK8U22zlt5nXSgkddKrVCIVu3JhkE8GvAMv77VnO389s1X1qouNRh6XcFpCSLt51z
7TAQRN8uJPlSEmfpmVLmdO8+IaX2rncY37IpvpFqAmrs4nB9dW4tbvL/Eqr29C8gRCWVZ
ByuzCZeXVt0OGG1T0aCbBCUDvgSoPjaViKQmqvNV9iMmEu7Y95VuKn6Vl9Ul1yYwC7A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="SW/gpPSw";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 54B95606A32A;
Thu, 26 Nov 2026 06:44:08 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=SW/gpPSw
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.180
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795675447;
b=y36mvMm4fxY+Qp874Lwow0qs9JmuWV3XrfgFxeyT1R7qIJAWROR2hIHwWWXn70FxIG+w
RH+1oHHEpY+j2IzeKxapjHjaDT/BICc3I9BfFmHDBQm7O3teGMkbtTGs6bMPreFOE2Nfw
0WRLIPDSVE9Xblw8sw7PaSh4A0EPVCEuj4xS+Xacb5QS6uriTPKw/v+cSBWl3M8YA7nE2
Fbx+MyFIGAD2l7cclTW390tO+fMo0D05Wa8qyOshcuYbFl1RvjZmFdv5e6jwB8q/vmwYt
W5IqWI7INUOof1cgGaHu+Dg8b/j44NNRuUlWLT+myeTTK+cJQaUngeriFXjYOAuIypw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795675447;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding;
bh=IGOZXvHj7Kp3VoWvYB9VXQ2RIbnpFsMHzOt42EfzF7E=;
b=1EVYUP5nUZx7hmU5YUdnDM3ESmnUHMcNjTENvjmq0i1TaZR3jGwVURSuDb138w3IEV6Y
ym3LP9Omgr4XMzIhfbTzXhrrW3xStKg/N1BmDOLm5kyn+tBC8hK5vDULjYrEmJwyUotEg
OQ2LwYoEXMl542xCieVfRrHlZcSn9LyuLCj8+ct5WIlTYI/VXqlLVf/DOYiLJ+wLpgZr+
mTaQXQhshBSVh859Ab60ncXw6OnCiRI4BD0VLVwAn7XzL1VaoNKIekISxfJQXOBzYcCXW
3n0XB3DR6kY80WFSNhX9L5GWWVkpBDAskVWhHMiLwA2DFtfI7I+KDUu0MiEXmhgFoDg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="SW/gpPSw";
arc=none smtp.remote-ip=74.125.82.180
X-Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ECDD606A31C
for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 06:44:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1ECDD606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-385c497bfddso690097eec.2
for <netdev@vger.kernel.org>; Wed, 25 Nov 2026 22:44:06 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795675446; x=1796280246; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=IGOZXvHj7Kp3VoWvYB9VXQ2RIbnpFsMHzOt42EfzF7E=;
b=SW/gpPSwuwYwkhXGjSM+9f/HgBYsqbFafnPdJDDbC5Qp4UMNOvjxX9xs8KaS4bZ4F3
erzj1yGSrxdCYoXeFv0PxyvDW0ORGraFyRdQAiwgDM/bjFHG5r1dTw7pPA03zQhc0azy
2f863bf113sAI02qZBZJkEaNI4aBIW1oHrE3udRHebf3kPCgRsHAThSkDJRZHAW5gR4b
XYCQp3fBBr0pOV5t8SH5Fkdn7RYiOeYF0im3ymbB0TUzHJq+HjWH5Y2ciDdZFWbfzW/N
wzVm2jIuVC32D4/hZLA7nO64nJPMHhsEEAQBljISj3P3Wfef71Jm0BctmbTS+jZMCVkT
CJqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795675446; x=1796280246;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=IGOZXvHj7Kp3VoWvYB9VXQ2RIbnpFsMHzOt42EfzF7E=;
b=uwroBJNYg+giVbg3Ol4n6FFPUZxBF+ZpnK9h5Rqi6l32BNrI+Vpixqmjcg0XNKIJ69
tUeKW6Qtx3c75TJs2gW1lf+lBnfZ7QYT9++2j1KsY1BCp+QloGSa1AJmGsnJQ+ory3PY
T3yitA1phNWRZxhgbkB9AO/3rhsbOowx+loN/ybkw9J+Q8tFuaTiWkjyQZmXipV8OdiT
G3mBGxY2yu6VnPA1niIJ+dHsBbwZNmHwUnnk2+0lIAh5errKLB2Gx3rNiHWHEGiejQTe
njCoNpK95KophetnRqG764nzzR0K9k2tK2Rc5nar51SqLwrv0UnepyHkBEeaxDxM0W/w
yoFQ==
X-Gm-Message-State: APuU4Z/RoZkWRTcKc5WXJCUiMWKzpmAzD9x3c/hfDeAVaZA6kkucJTSF
HKJBBIWBablTnmMIkFS2/CfJVuNSw5q1eRPZqTWGE9WQZUsykoIGdSOf
X-Gm-Gg: AZFdTZf1lCELwIV3LCl0yWNGaXUeilm5vn3XsKKuo00Vjr6sBnBeKjprK0gSxw1/WBA
EEeH5n9Zau+MTr0VQwhATZoVv1/+ZBQwzjuz6wbvyKOUqw/vQBgaJfVm6YGSaLyXOKFEcVin4H4
ryQ7133pxmmhGHYRttdfAQSsjsJUTWn34y2aHRpc1WZBSiA2kj0BbhcwlATSSyxqCrk8FLRuHw9
QhWuuLna3fj876xRbRD1Wks4K0wqyugqlC0vckkQaQIfxVxxsz3o8A0fMUzb2lhm3150mLDSALZ
Mz9zInEoTG6j395qtlao5uZO6Y5tbbG9mUxs2RJ4cJMkJ9g3Sht1OLDdfsu4T4SOKl77GuGpKN8
DDF3/HPf2Sg9Y4zENOgAmZNGudLkLSLMEKjcLfEwfpuKx/9jQcZDOl32NFDxfkQO168r4k48Ewt
g2hSnLOmHp0dYppayACUqyRskojhtt4xK9b9PUTDzArt65mpwgmN5w8RuvkbL4E1dqdVFFHTVhF
5Cc7sM7OCGOLLVvGiDpZEDAsK6JMqCwTMYDLWhkUzQoDO2gk1KNPZ4fZ/FO/e+3GA1HyaGbemYO
d45POzGH7IBCU59AyWdIzGG7WY4f36GtYDLurLz7Lzq363BgWECHYA==
X-Received: by 2002:a05:701b:4558:10b0:183:d275:cf76 with SMTP id a92af1059eb24-1b5568bfe8cmr29796063c88.2.1795675446057;
Wed, 25 Nov 2026 22:44:06 -0800 (PST)
X-Received: from localhost.localdomain ([14.47.155.101])
by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b556829d31sm76548135c88.9.2026.11.25.22.44.04
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 25 Nov 2026 22:44:05 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
anthony.l.nguyen@intel.com,
przemyslaw.kitszel@intel.com,
m.wilczynski@samsung.com
X-Mailer: git-send-email 2.54.0
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