🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4533

[PATCH net v2] net/sched: cls_api: unlink indr cb on a failed bind

#4533
From: Qihang
Date: Sun, 18 Oct 2026 11:29
91 lines
11468 bytes
When a device is bound to a shared block through the indirect flow-block
path, flow_indr_block_cb_alloc() links the driver callback on
flow_block_indr_list.  If tcf_block_bind() then fails, its error path
removes the callback from driver_list and frees it, but leaves it linked
on flow_block_indr_list, so the next flow_indr_dev_unregister() of that
driver walks the freed callback.

Remove the callback from flow_block_indr_list before freeing it.  That
list is protected by flow_indr_block_lock, so do the unlink under the
lock through a new flow_indr_block_cb_unlink() helper.

commit da94a7781fc3 ("net/sched: cls_api: remove block_cb from driver_list
before freeing") fixed this same error path for driver_list; indr.list is
the link that change still misses.

flow_block_cb_alloc() initialises indr.list, so the helper is a no-op for
the direct (non-indirect) callbacks that are never on the list.

Fixes: 1fac52da5942c ("net: flow_offload: consolidate indirect flow_block infrastructure")
Cc: stable@vger.kernel.org
Signed-off-by: Qihang <q.h.hack.winter@gmail.com>
---
v2:
 - unlink the callback under flow_indr_block_lock with a new
   flow_indr_block_cb_unlink() helper; v1 called list_del_init() without
   holding the lock, which races a concurrent flow_indr_dev_unregister()
   walking flow_block_indr_list.
 - initialise indr.list in flow_block_cb_alloc() so the helper is a no-op
   for direct (non-indirect) callbacks.

v1: https://lore.kernel.org/netdev/20261013162949.25622-1-q.h.hack.winter@gmail.com/

 include/net/flow_offload.h | 1 +
 net/core/flow_offload.c    | 9 +++++++++
 net/sched/cls_api.c        | 1 +
 3 files changed, 11 insertions(+)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 70a02ee14308..b8ca8cc0a241 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -640,6 +640,7 @@ struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
 					       void *indr_cb_priv,
 					       void (*cleanup)(struct flow_block_cb *block_cb));
 void flow_block_cb_free(struct flow_block_cb *block_cb);
+void flow_indr_block_cb_unlink(struct flow_block_cb *block_cb);
 
 struct flow_block_cb *flow_block_cb_lookup(struct flow_block *block,
 					   flow_setup_cb_t *cb, void *cb_ident);
diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c
index 5071d7fe6ce2..62bc2eb6e0da 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;
@@ -525,6 +527,13 @@ static void flow_block_indr_init(struct flow_block_cb *flow_block,
 	flow_block->indr.cleanup = cleanup;
 }
 
+void flow_indr_block_cb_unlink(struct flow_block_cb *block_cb)
+{
+	mutex_lock(&flow_indr_block_lock);
+	list_del_init(&block_cb->indr.list);
+	mutex_unlock(&flow_indr_block_lock);
+}
+
 struct flow_block_cb *flow_indr_block_cb_alloc(flow_setup_cb_t *cb,
 					       void *cb_ident, void *cb_priv,
 					       void (*release)(void *cb_priv),
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index a9f54988561f..9e4ea3715419 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1665,6 +1665,7 @@ 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);
+		flow_indr_block_cb_unlink(block_cb);
 		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: <20261018112955.61470-1-q.h.hack.winter@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348016-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-348016-linux-kernel-netdev=dewy.ru
From: q.h.hack.winter@gmail.com (Qihang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2] net/sched: cls_api: unlink indr cb on a failed bind
Date: Sun, 18 Oct 2026 19:29:55 +0800
Organization: Usenet Network
Message-ID: <20261018112955.61470-1-q.h.hack.winter@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3307763"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:NMel8m/TKGm8U9q4hG9GRzM3A7I= sha256:IajAIIOZnstBVZD3BKGgxYyIeKL97+VwZ7tXi+yndc0=
	sha1:E/xRtnC8E34uGFyziQoLF1Z44vw= sha256:wrmToqewwPzKcBT5bL33t9Lio72rsFQXMqiAwzZnc44=
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 7D0551107F8; Sun, 18 Oct 2026 14:30:30 +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 kddwdnT4_j87;
	Sun, 18 Oct 2026 14:30:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-348016-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id F284C1107E7; Sun, 18 Oct 2026 14:30:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by sin.lore.kernel.org (Postfix) with ESMTP id B214128F23; Sun, 18 Oct 2026 11:30:07 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A6E7447C0EB;
	Sun, 18 Oct 2026 11:30:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PjjZIECs"
X-Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177])
	(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 3D84B476059
	for <netdev@vger.kernel.org>; Sun, 18 Oct 2026 11:30:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792323006; cv=none; b=Lb3lCQhfL0aB/+r4jZbzRtCYlvyKTesbaBmgl+4Kzn8Bdq0t7R97CJMCB1zOKKBodDK5vLkNMclmW5jrZci0efWNNcKdtbtNqFstQrtaqQnaLZvLiPIvaw2EfMl6/v2Fkc8Rky/mS9HnuJAYw3D59GISE4nKezMPPplsidLs8A4=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792323006; c=relaxed/simple;
	bh=z9mZ1nkUPH//WXspdQ7uPbIwDfgZdqWERRmaO6Hli4A=;
	h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=P4qmvmtvB02OoTFGYCEZqdseSqkWxm322rjDNrOr/Tp6elsXN82hxR4DIioxdXjnPQcX/uCMg25+Mhdkw5BSZpz7ffkif5zTMuyxPhOW0x1KZSTE8MuE77OG/ADDBwJGQ1EHklFam4Z+fTxtj+usXEc4m95PcRLT8A2to13jXeI=
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=PjjZIECs; arc=none smtp.client-ip=209.85.210.177
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-pf1-f177.google.com with SMTP id d2e1a72fcca58-89dfec5132dso26928b3a.2
        for <netdev@vger.kernel.org>; Sun, 18 Oct 2026 04:30:04 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792323004; x=1792927804; 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=iv8yp98/kiK12Je0YsBkzTzUev6Y+uj8yzE4h7Pr6dI=;
        b=PjjZIECscdpymnIA8mlSUDvnOisC/CEzSRhDuh4PSFSuxAydCiDWzWNU7OUw/9vmuR
         3RvFPYbWyLVexONIdOUMPF99MjfqYDr0xw0YXW89kYtrthnVfzHvwtvbwp1w9RLJujd9
         oc384QEgZWLwZ9bxIpOhJpVFs8wPJSveGfrlWUY0UeUk08gZiMXW/tZN80+s7IZQxnD8
         vyXm0Mno8/D1jRAIlHrdY7r2EuKxbViXYRBINYETj1mMHL+03jGg5OCn501IV61HonFq
         X4s5g8Z2NdtLlE0wFGvVfzWqX9B9Sl/WRNLTT0gwu7VMEpO/jsj7/y+KCEE8ctr7rZGk
         +31Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792323004; x=1792927804;
        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=iv8yp98/kiK12Je0YsBkzTzUev6Y+uj8yzE4h7Pr6dI=;
        b=TvxMrQSIqEz+t2lukx1X6OoJEFZJcyVe24oVmX87AIiumO6kw8E8iOCBzBL9p1osrw
         RwNMkMZ2lvML7go3x9RQvAR1bfpV7aXpXTPrUrvuL5/LKgZAVIRWr+XRpj12zjyUy8Hr
         jXAoOQMYOYBdbg5oocJJZDWSLv0B1Ny2Yueee0Rpiof8rUG7wQ25uyZgVISHqOGAes1I
         iJlauTEOTnYWn6kT37k7CC9uNkfDFMPB3jgvHpWsJObHU/N9Xi5b6mIc/H+d/b0+o2rc
         eP2lZDeCltBsFemZupYoKCkxJWHPJLK9evGADiPbsHnZaT4mBmT+ZcqBvxQ4YI8JvFp5
         NkDQ==
X-Gm-Message-State: AFq9FYJg0pQty6x6nPncaSQeWavxuufI0QehVNZzMBFhMM0uWt2UnxaR
	sTDL5ug+6t4cfetsEVYkgSFyuluJOzXXzfHnNnEx4wJrSW0SknSMf0w6
X-Gm-Gg: AYBFou002KttFGafU9LV4etxMKNp7qnwf8RlzgmFMF2jnFozHa1Vncmh6MjP+IDlhV3
	bNI0dEVb2MojqxQpOavQpsbTj2a3JQOdBI+PHUPFHXJqLhqW/S8C0AwiGkCrZPymIHyQyja6n/n
	iDYta/9PN3cNaH73XhWRjDaOP7bGEMpqp6tZPz3cOWyIsy3OeZacLfCtTsKXpXD5CRyIiS8dfBq
	zZj4jfZWlenH7eOb4uhzQJGGc5jSVIfBejzHMPBKmYxUK3fa4nitGep1L0v2OjQNfb5/gzh7/7m
	v5BXZP8ozKzs/tiql3i709uRr2iALGKbjWRbp0DsgV9ynVdD0OR6wtjnjv+D9iYs41U1ja9Qqz4
	czmgQqBen4396VZc7+nA1vWrLmlTyjvcB+ThMCJ+ups7FRgLOPnVgelQe93ZnuRk0NgMBq/pDTg
	ikqgf3gqHNSmj2LCAJdqisyoZvHCzBAlEYFOhMGa8TMy7/5Ws5IEHO7QN/wp/4Pd4rVVXkcjedU
	Tcpp5Cgam+xj88U/Q6GQafDfn0nOq4khqrmF7vmOyf2uDzDM0mwkz+bOf9fxhw+l6A=
X-Received: by 2002:a17:90b:48cf:b0:3ac:e6a:1af5 with SMTP id 98e67ed59e1d1-3acee6f12famr6963832a91.2.1792323004381;
        Sun, 18 Oct 2026 04:30:04 -0700 (PDT)
X-Received: from localhost.localdomain ([113.102.237.20])
        by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3acd9c4b4eesm9195365a91.2.2026.10.18.04.30.00
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Sun, 18 Oct 2026 04:30:04 -0700 (PDT)
X-Cc: netdev@vger.kernel.org,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	pablo@netfilter.org,
	stable@vger.kernel.org
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>