Article View: linux.kernel.netdev
Article #2890[PATCH net] net/sched: cls_api: unlink indr cb on a failed bind
From: Qihang
Date: Tue, 13 Oct 2026 16:29
Date: Tue, 13 Oct 2026 16:29
67 lines
10573 bytes
10573 bytes
Binding a device without ndo_setup_tc() to a shared block goes through the
indirect path, and when that bind fails tcf_block_bind()'s error path
frees the driver callback while it is still linked on the global
flow_block_indr_list. The next flow_indr_dev_unregister() of that driver
walks the freed node:
tcf_block_get_ext()
-> tcf_block_offload_cmd()
-> flow_indr_dev_setup_offload() [ allocates block_cb and links it
on flow_block_indr_list ]
-> tcf_block_setup() -> tcf_block_bind()
-> err_unroll: list_del(&block_cb->driver_list);
flow_block_cb_free(block_cb); [ kfree() ]
-> err_block_offload_bind [ no tcf_block_offload_unbind() ]
The only unlink is flow_indr_block_cb_remove(), which a driver calls while
handling FLOW_BLOCK_UNBIND, and a failed bind never delivers that command,
so nothing removes the node before the callback is freed.
commit da94a7781fc3 ("net/sched: cls_api: remove block_cb from driver_list
before freeing") fixed this loop for driver_list; indr.list is the link
that change still misses.
Fix by unlinking the callback before it is freed, and by initialising
indr.list in flow_block_cb_alloc(), so an unlinked callback carries an
empty list instead of an all-NULL one. That is what makes the
list_empty() test exact for the direct and the indirect path alike.
Fixes: 1fac52da5942c ("net: flow_offload: consolidate indirect flow_block infrastructure")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Qihang <q.h.hack.winter@gmail.com>
---
net/core/flow_offload.c | 2 ++
net/sched/cls_api.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index 5071d7fe6ce2..64451129a230 100644
--- a/net/core/flow_offload.c
+++ b/net/core/flow_offload.c
@@ -266,6 +266,8 @@ struct flow_block_cb *flow_block_cb_alloc(flow_setup_cb_t *cb,
if (!block_cb)
return ERR_PTR(-ENOMEM);
+ INIT_LIST_HEAD(&block_cb->indr.list);
+
block_cb->cb = cb;
block_cb->cb_ident = cb_ident;
block_cb->cb_priv = cb_priv;
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index a9f54988561f..ffbb8353251b 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1665,6 +1665,9 @@ static int tcf_block_bind(struct tcf_block *block,
err_unroll:
list_for_each_entry_safe(block_cb, next, &bo->cb_list, list) {
list_del(&block_cb->driver_list);
+ /* linked only for an indirect bind */
+ if (!list_empty(&block_cb->indr.list))
+ list_del_init(&block_cb->indr.list);
if (i-- > 0) {
list_del(&block_cb->list);
tcf_block_playback_offloads(block, block_cb->cb,
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261013162949.25622-1-q.h.hack.winter@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345734-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-345734-linux-kernel-netdev=dewy.ru
From: q.h.hack.winter@gmail.com (Qihang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] net/sched: cls_api: unlink indr cb on a failed bind
Date: Wed, 14 Oct 2026 00:29:49 +0800
Organization: Usenet Network
Message-ID: <20261013162949.25622-1-q.h.hack.winter@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2137292"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Bt04qd7IdPnYK7coxJB4YR16h74= sha256:fFuU7+e7EGO8wfepBuizZ3szsv0G9GsdUoKAK+vAaLE=
sha1:/N2pBZP96rihzG4+6cAecMGoVnc= sha256:WagoQpr6hYn+hIKUjqTS97HWpKtWGyYNCA/FEG/Whlc=
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 9F7EE10FEE5; Tue, 13 Oct 2026 22:37:08 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.748
X-Spam-Status: No, score=-0.748 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.25,
MAILING_LIST_MULTI=-1, 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 rjBiS3rTpYKs;
Tue, 13 Oct 2026 22:37:05 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-345734-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 5E55110FEDE; Tue, 13 Oct 2026 22:36:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by tor.lore.kernel.org (Postfix) with ESMTP id 9ED81124CE5; Tue, 13 Oct 2026 16:30:30 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id A32D147ACD7;
Tue, 13 Oct 2026 16:30:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q4WnDvVY"
X-Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id D821151C057
for <netdev@vger.kernel.org>; Tue, 13 Oct 2026 16:30:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.45
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791909013; cv=none; b=WYUFoa+DNH5wzQ/wv3YI7D25L/MgLSmfGjP9wVQrEJWuwBgGnkt8j793S1hUcluy48156nVCaQnDV0+/yjUY9ebSO/CI+KGKCfPQFsoADjlplrbLc3T8KprbhNwz7xGPCyxEVvWNdik9bECXqpWEgjcJousTs8pfNKl61ACTJUU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791909013; c=relaxed/simple;
bh=+HGJ91G3vE8I+hjbAj7JZo7VbwjxkPRsRJSUwJ2/ZT4=;
h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D3aT0W+cnhblsmaMFkIa7ZbsUVmNdvhlfEzYqI8mLqAeI++YwppRaWqsqdXJal1YD73O2C03ugWQdklhDc2iIvE+Wfd7BqcEIyUy3jKozqhXvbGiHgJDgksRlBe1CLVt3nVDir+1z4rS0e49xtcp6j0Mqe/U3P7G/B/B5BcLLqk=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=q4WnDvVY; arc=none smtp.client-ip=209.85.216.45
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-pj1-f45.google.com with SMTP id 98e67ed59e1d1-3a47d4fb7feso181219a91.0
for <netdev@vger.kernel.org>; Tue, 13 Oct 2026 09:30:11 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791909011; x=1792513811; 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=T42dDgF1G2T5CFLnp1NKvSC8C3hiWB9MunCO19ie1Ug=;
b=q4WnDvVY9KFvleeUiwYCCnDKHr0HfGtB5+souZNmraxCa8/O/JXWVXY2DRetFRmxyv
kXgDTp5pMq2yglZLJspYA6FObraIuVGSv3Zb6+qomYZrkTZ95lStW+ohZOSW/9LoYkMk
0LDqmAl1Orw3kriRlCmBTvC0VGQcwwG/8AXOfUVVWpu7N9BsjUuSBNlInAJKMbpJQklK
BddxUQnvz2e0ky42lEHzNQ6AlhDDAFH7LfStAkl5Fgon36ARuAmrVAMdHvkPyIrCQmtH
YxC163qCa2qJIlDAzMQnFZIYbLKwEcz5u2s2ONP/AxoAvhLGMdSQW35fjdmRNReWCLFH
2cwQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791909011; x=1792513811;
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=T42dDgF1G2T5CFLnp1NKvSC8C3hiWB9MunCO19ie1Ug=;
b=fJXZBmOwWfkPduDp0viJo2GIyMytZBxouJ/BKHoOa5xVPUcxbzN5INgqo6jQoWnR8p
x1lU+3WXeAspbvc5YvmbQcpQyRV4i7P40V8J53heqvuK4IyzCP8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DT)
X-Received: from localhost.localdomain ([119.127.198.225])
by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cd3d9e26ddfsm5672992a12.17.2026.10.13.09.29.55
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Tue, 13 Oct 2026 09:30:07 -0700 (PDT)
X-Cc: jhs@mojatatu.com,
jiri@resnulli.us,
davem@davemloft.net,
edumazet@kernel.org,
kuba@kernel.org,
pabeni@redhat.com,
horms@kernel.org,
pablo@netfilter.org,
stable@vger.kernel.org,
Qihang <q.h.hack.winter@gmail.com>
X-Mailer: git-send-email 2.54.0
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>