🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26390

[PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc()

#26390
From: Jedrzej Jagielski
Date: Thu, 03 Dec 2026 12:40
57 lines
11363 bytes
Remove the redundant refcount_inc(&ht_old->refcnt) in the
u32_replace_hw_knode() error path during filter update.

Commit e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed")
added this increment to "undo" a decrement performed by u32_set_parms()
on the original node's linked hash table but apparently this decrement
is already balanced by u32_init_knode(), which increments the same
refcount when cloning the original node:

  u32_init_knode():        refcount_inc() on the old ht_down
  u32_set_parms():         refcount_dec() on ht_old
  __u32_destroy_key(new):  drops new->ht_down

These cancel out, leaving the original hash table's refcount unchanged.
The additional refcount_inc in the error path has no matching decrement,
leaving the tc_u_hnode refcount permanently elevated by 1.  This
prevents the hash table from ever being freed, leaking memory.

__u32_destroy_key(new) already correctly drops new->ht_down's refcount
(the new linked hash table set by u32_set_parms), so no manual refcount
fixup is needed.

This is a forward fix for currently dead code, which will be uncovered
by the upcoming patch "net/sched: cls_u32: feed u32_replace_hw_knode()
with correct set of flags".

Fixes: e8d3d78c19be ("net: sched: cls_u32: Undo refcount decrement in case update failed")
Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260807100356.1083774-1-jedrzej.jagielski%40intel.com
Signed-off-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
---
 net/sched/cls_u32.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index c544c8e4e876..ae1b6476f921 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -954,14 +954,6 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
 		err = u32_replace_hw_knode(tp, new, flags, extack);
 		if (err) {
 			u32_unbind_filter(tp, new, tb);
-
-			if (tb[TCA_U32_LINK]) {
-				struct tc_u_hnode *ht_old;
-
-				ht_old = rtnl_dereference(n->ht_down);
-				if (ht_old)
-					refcount_inc(&ht_old->refcnt);
-			}
 			__u32_destroy_key(new);
 			return err;
 		}
-- 
2.31.1
Technical Details
Message-ID: <20261203124056.547555-3-jedrzej.jagielski@intel.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-376617-linux-kernel-netdev=dewy.ru
References: <20261203124056.547555-1-jedrzej.jagielski@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.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-376617-linux-kernel-netdev=dewy.ru
From: jedrzej.jagielski@intel.com (Jedrzej Jagielski)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 2/5] net/sched: cls_u32: remove erroneous refcount_inc()
Date: Thu,  3 Dec 2026 13:40:53 +0100
Organization: Usenet Network
Message-ID: <20261203124056.547555-3-jedrzej.jagielski@intel.com>
References: <20261203124056.547555-1-jedrzej.jagielski@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2496673"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9KAjIrVBh2TdJ2vqB4wo7UdcQmg= sha256:8+19p/E/uVmSPs0JTTBGQVP0FUJgzn+jgshCQN2Tpjw=
	sha1:skkC8o2vuOHmf5DMtlKQdDlL/MI= sha256:5crr62Vt5cVi0P+LgeM0einfiPfDMTHCgNL2gTvRxoQ=
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 EEF8A11794D; Thu,  3 Dec 2026 16:03:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	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=intel.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 3d98zuP3eza8;
	Thu,  3 Dec 2026 16:03:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376617-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 5BFB7117951; Thu,  3 Dec 2026 16:03:35 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id F0734602E54; Thu,  3 Dec 2026 13:03:34 +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=1796303000;
	b=HBZCSnYDjR6clbgV3c+SicoD/SxajTomyWfJ1KeoZ3RPKErvP19/kTdMHVqJnXFbzJop
	 3HmZobtgnD+QxZwRHCjHBWRVYkd5pd67IY2qxMQrqsOcbwimwVM602weyj5RuTtmGGdAo
	 rPggBEfVCNrfQoI53dRw1LvBOIn5JLoO2MT3KTsaD7aq9FoSM4mghw1zgO23KWQxms+Z0
	 lLx2oLqRXBsQl8pSF21LHHkhAXzdkHmAqoBAK3rrJoLKptROwyOmu52oGzFwI3PcifPkl
	 Y/IQbHlukPrYU/7fH1hGQ7mANc38/Omqec8PeYNkrfk65UZr88qMFOdYplJJkZYjZfQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796303000;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV:
	 Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:
	 Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=+VpmnhZFzEp8p6OWNFHfksbMeHhmRasmWk4QUvf2oNU=;
	b=IcuE03FeiPbbM3U0Zi/EmcStb1dgdCbHb+1+B7jArLUGTUzyrrIHAwWMeZcFodExWXiV
	 JR+EfdGtCsgK2KL29A7/Vv5LIx+REh8pxE9cQytvxTBTS79bjJK3U4qwvy+YWhI0Jce1C
	 gQbQWLCKCBUTBKNb2CZqpFZnr++5SDGhPOnZlAt0vpPjQILmCwzQzPshMlSc7fuWl0I7u
	 aViboR6d9YNyUqcJw9i4lVW6ZtHjplAPeRdFvJ4sXUWZaY/psQwJP+ghG8F1NeQ6n7o4l
	 SL+bpb9pFGMa38TRS+dRVeqdXWepYfwbiucnYVfxSoklN6IHH5SCLOTiwkYCDfhuJ/w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NYvhndK+;
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.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 4C87A606A697;
	Thu,  3 Dec 2026 13:03:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NYvhndK+
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.21
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796302999;
	b=V9/6Yay758ayQ1WP6D7Jt+7QYxsN+L8mzehauQ71g5geU+4wbHTgITEzeVLFW5dZ3A1D
	 K2PRne5YVtYZfZ8OBQVdTb9DOLBzKiIR03VnGfXsDSrTlR2jXudEvpN37am3dWgBCtnCv
	 r7yEsm2xIfyPKiRszJ8T52snSeHp77WXLndmwb2jXLiDgZRuZYeu5fDvQWB9LSval9obZ
	 EsI3X7nLKdkQ4TOk6Qte1B5UGTlUlsVNHCSxAF+M2PMRmJ074erBuY28aJ7Um2SznmJzf
	 SbJMfIahuimsZwiDhUj3YUtBCY2w68ivY/K0h0RXTUvTVCCUF1zo/xqqbG4wQmVQrmw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796302999;
	h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:
	 X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID:
	 X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject:
	 Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=+VpmnhZFzEp8p6OWNFHfksbMeHhmRasmWk4QUvf2oNU=;
	b=e3jrt2aIkFJYSghdBPTzrTjUMkE7zKLl2M99568MXx6UMVdYP3vQEFWAexhn3qIKxZcF
	 Ikq6RAyT7/95QNV82ONTyZCZ6PnA/Vq0ruJ+hHqFDTWWsfy+yE3j+sUdFiG6lVkO+VIS4
	 VkzeEVho20RlBnv7SEv+fWgYEeKF3vUcqcUHveE+Oa2xQVsSV0YtvhcbAvp+P7cGc5ZNQ
	 wgqKYlla+sNNrMSLFGsgoN4dDvKzU94uBvLSbf1sEQhXl2oEhdi6t3A7dMbXQJlHJWoeQ
	 90f2jbczWxYXjTDQ3GwSinytO0qs1+r6dU2cc84s1ow/1uSOtCl+amGkK+JcPYJe3bw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=NYvhndK+;
	arc=none smtp.remote-ip=198.175.65.21
X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17767606A684;
	Thu,  3 Dec 2026 13:03:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 17767606A684
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1796302999; x=1827838999;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=+VpmnhZFzEp8p6OWNFHfksbMeHhmRasmWk4QUvf2oNU=;
  b=NYvhndK+ORzxlfZFJJ8nR0unEYyjxbWavic9dNuGgkVqw8dx4XggmnHC
   WNHHSP7LWdlnmwr7IUZ5CUAz970HR+lHm80+jQXxN7FedCr+mAkPEG9qT
   gzaZtZKaOObff9jDg1WEnye51JIJNveEv/R7tXBDHYhdSKwreVLchHoKM
   pErMPCHMDB0r/tKTUhfxBXbcZa/Dav3YUn4d+iRWb7bl6EM01WkvGNn8r
   Ew+bmwtuh8N4ykIsfZS7qRIgHcWQUanGuXJmvsRBMHq02FUcm2pz9Fbdn
   wxyw9G9/fepqqlOc+aLTLZEqrdC6bKFesJBV1DHSzNLlv38Q6w+iW5YOz
   Q==;
X-CSE-ConnectionGUID: 6dnMPgcwSgakwqkM/GM5Uw==
X-CSE-MsgGUID: w4mI7XvKTN2EHj9yihztXg==
X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5366921"
X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; 
   d="scan'208";a="5366921"
X-Received: from orviesa009.jf.intel.com ([10.64.159.149])
  by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 05:03:18 -0800
X-CSE-ConnectionGUID: 40NOU4uxTv+a+dijHCNTQw==
X-CSE-MsgGUID: oq/W4AQlTSC+Ifaocg+98w==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.29,248,1794902400"; 
   d="scan'208";a="14195738"
X-Received: from os-delivery.igk.intel.com ([10.102.18.218])
  by orviesa009.jf.intel.com with ESMTP; 03 Dec 2026 05:03:16 -0800
X-Cc: anthony.l.nguyen@intel.com,
	kuba@kernel.org,
	jhs@mojatatu.com,
	jiri@resnulli.us,
	edumazet@google.com,
	Jedrzej Jagielski <jedrzej.jagielski@intel.com>,
	stable@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>
X-Mailer: git-send-email 2.31.1
X-In-Reply-To: <20261203124056.547555-1-jedrzej.jagielski@intel.com>
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