Article View: linux.kernel.netdev
Article #24747Re: [PATCH net v3 2/5] net/sched: cls_u32: remove erroneous refcount_inc()
From: Jamal Hadi Salim
Date: Mon, 30 Nov 2026 19:07
Date: Mon, 30 Nov 2026 19:07
70 lines
14474 bytes
14474 bytes
On Mon, Nov 30, 2026 at 7:52 AM Jedrzej Jagielski
<jedrzej.jagielski@intel.com> wrote:
>
> 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>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
> ---
> 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:
<CAM0EoM=py-CnAn3kCarnAHXE8ok-u2PL-jUPgFMVorv4PLvd2w@mail.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-374397-linux-kernel-netdev=dewy.ruReferences:
<20261130123028.516696-1-jedrzej.jagielski@intel.com> <20261130123028.516696-3-jedrzej.jagielski@intel.com>Show 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-374397-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 2/5] net/sched: cls_u32: remove erroneous refcount_inc()
Date: Mon, 30 Nov 2026 14:07:41 -0500
Organization: Usenet Network
Message-ID: <CAM0EoM=py-CnAn3kCarnAHXE8ok-u2PL-jUPgFMVorv4PLvd2w@mail.gmail.com>
References: <20261130123028.516696-1-jedrzej.jagielski@intel.com> <20261130123028.516696-3-jedrzej.jagielski@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="1511073"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:qS5rBxMxCA6dKpMFVwxntWrP3mE= sha256:aTT3LY9pPi1bWuW0QL8308Qnjz/b8nVMRCfEjobE568=
sha1:BLsSFiyY89U1dXN7P+Oyew6uQv4= sha256:wVxpHvTPY6VOpyBlWfy/oehQuEzqpxeix90AWySJgW4=
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 23D9A125FFC; Mon, 30 Nov 2026 22:08:14 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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, 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 (1024-bit key)
header.d=mojatatu.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 3VssireEfnEU;
Mon, 30 Nov 2026 22:08:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374397-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 0A276126001; Mon, 30 Nov 2026 22:07:58 +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 53EE52658D; Mon, 30 Nov 2026 19:07:55 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796065675;
b=iDHCNaQkGnwIdQOCCfb2yLYcI5KuCPXoH4/BQJRWPheekC62G482cqMOq3Xxhp/zgn86
4EAQ7UG+ZTRew9Z1n1Bj3FHtD06Jg4GegwAcqshirtdZ3ja22DWwxVZzRy29qU9ZdT3+Y
/2+SgZiBUzynmVQtBp2qUpxvTDjlT+k8R9qwruWmX6URAUFJxrF5HPkL+qub7blL+YXla
eTG25cRFUhO6e3yRDtDYFQBwRdibaK19RagmQGmkxUSfSbM5iP/ocqeLB02EJ/18tKBY8
0ig3vcxeWFuM7xF8o5va5vD1DhUQ+Ev0Bt3k4/aSFeflxtocXd/hf6/5CnbOr4BRQjw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796065675;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:References:
In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=jWNzm0xVD8BTEnq2laHMxXvSwybqfzhxcJOgeeO6zrE=;
b=CscXfI8vjNDu65vj7sOsvhSpSJRTFNdC1FpeLLvILQvOguXOXE+UmtL4qdkzPn6Fa0/h
dB35lb7LT/9+Qym6xrnSMbQwGiggpW7Rm3ODZMMYt4iqBLDXXSrccTUP1ixcHbOc9dByM
vbKrvRMiaxH1Z52KuPo+sFj+0QvWIpOcGu/S1dNilyD4vQ2Prj6cAu2GhwH7mIgYoAyz/
5GkAIUldkxWcnYz4hzAOqf3OpPQyfic3lG4aDJzXWNvEy8aKK43NO3n1YOyP21b0kFNyX
2j0DqwEby/fVIf3zT0DDLh2LSp1nabg9EXvY1hHKS+3Ex/uXypBWtWRaDimg7eY5Z4g==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=ZgUnbuFo;
dmarc=none header.from=mojatatu.com;
spf=none smtp.mailfrom=mojatatu.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 2C097606A32E;
Mon, 30 Nov 2026 19:07:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=ZgUnbuFo
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.215.172
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796065674;
b=LmJTkjXKNblVmtcv6WAmzYh6oFLNKWJzBtLMlao+xT+kzmq8EWAEgo3M14oox1dyV0R4
w8GWewOA5azwVcMkUSUtvWewxOJEIP7cPsBFFRDZ+Yz6zvdqBGXd4RcBAotV8VS/zZnnt
7XtlojLa4/jLIS/5e++AE3XkxkIWusqpNnOQaSWCdzM7GbDvl7O/2ydLOsRCCybI6RKdU
s9u/2m1sXKuyq+srgVui05+BYcF6teUnBENzzEWH070czcJLHblZMGYoHpO/blIZE3AwG
rS2lhb2Wnxwzxf2cEiFl2oic44ptTmrpXeQaoihG13TrShyWjnQP9y1qmKS2VmRGulw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796065674;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:MIME-Version:References:
In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type:Content-Transfer-Encoding;
bh=jWNzm0xVD8BTEnq2laHMxXvSwybqfzhxcJOgeeO6zrE=;
b=t/bKo5uWulFpUYu3aC1TXjBbYuZ18QjM1Dn2b8Ayey3kAHaSHyNGbqgkY6OugLGcCsKF
s3pFxtRQbg/nDaCtG4uwH/nO6/Epqqo1i80lWwja5l+y++RoycttGVeUPGNBV/e2TjcpW
wr7Xtl3BLM8P9af3FaEE9VXJBCX62QmRnktQ7rr4QhkBDybMo2B8MVigxIMbg3Pu61a+A
2D1jkoMJfIz9k4Bgg/V2zxNAiGxfrb5z+ak75Cct7fgYlp7+gF16v2SzwGT1JJP/rJCp0
hAekO36fbr3cPiXB3qsH2ezn0TJF6PLMPWF75CQxLLuuwIJMxX261R5uUdCRZ0b4Jdw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=none header.from=mojatatu.com;
spf=none smtp.mailfrom=mojatatu.com;
dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=ZgUnbuFo;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.215.172
X-Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172])
(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 70674606A31C
for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 19:07:53 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70674606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-cde5a7d79b0so5509607a12.2
for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 11:07:53 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1796065673; cv=none;
d=google.com; s=arc-20260327;
b=deJNqqu3BUQ1fASAc66roo48Kl79gupuz4G2rH1peqQUpBq4Ok0SrWEr7zXQsbRZjl
P0o2DSTM+9k+BXFGetIqGIOJpvBg/hRRpJzTDneOYwxSR0gcSmXzj1rv8oc4Cy7U3q55
PV83gh+Zu6aWZURIGkRGni6LfZ2mUIUf/gP7wCWsnNOuAow7SEJkeLl5SA+vx7YFoQgO
FXQB8cCAmgbZRyfdC+MretrSobimNfJDtFQnlM8YLe+NxD1JafH1xk4kicdS+H/iMwyj
wTyjzx0lGGV6D9htJQ6yQCDoC7jpC8WrkvG1pnaXsuGXFvlqi7Uw+6+ANoZoN/WxXNYW
VHeg==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=jWNzm0xVD8BTEnq2laHMxXvSwybqfzhxcJOgeeO6zrE=;
fh=dlVy2H69TsIr6/kV18oBxbbbtjA5NSfZcJaY7jwY2Ro=;
b=ODS71kE0tA2xoZVdQ+hvYDYFIOJIM3AeD2oII+0A0+94/xEHm2AJV+Ic8d13hkOqCq
MYu9SLa6XL5MutDRiTQm+DgPcGdTQ12Eea8JfaCt1gdA0XI7hhmEwJk773NipfMjkcQ1
DG2/uwMbmro1egIq0bV36gMzy+s9e/3WSpr4iMTv6rmkO32iuWlQq9UOd9nvaP8qySkx
vlswgPxpvJoXqN9Ivhcy5/rl1OrdCIZAC6E9s6ioKklrtP06nH2OtKXYrruvkDykdfRf
cddooXYTJRdbz2NjgrwAoJNsLg6R+hs+4POV2mC4ZVV2pvqjJpB2k4byAVhVcwloXzy2
bblQ==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=mojatatu.com; s=google; t=1796065673; x=1796670473; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=jWNzm0xVD8BTEnq2laHMxXvSwybqfzhxcJOgeeO6zrE=;
b=ZgUnbuFoWUxSpLyYySwZZf3PI3IVnVa4p+SL4oLFWsgxzt4/2l+fC+rpqdRu7Hl+oh
GQDBpu1HHjRTC+A5XCwlwgFElbswU9lXCvWXeaLjJejOxWl/lwnNuVAAlWlvtQ5feYgB
VEde8ft6KFZzFLxkFY0p0wZgdO5+1M0b5UrQg=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796065673; x=1796670473;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=jWNzm0xVD8BTEnq2laHMxXvSwybqfzhxcJOgeeO6zrE=;
b=06ARC6/v4YFcrEUtWWDZTuIsAtDTLEbH+uBvcGY5qiP75QRx5hKv4nGtX/WrZpzF+8
bDrJo1xdcD/wymUOZ8Zu8jAvIGymyqv1MZNi/4jQ1ETWA4VXafNorPDoPNDE+pZ8pgci
FV2ZRDolX+CbNe+Mv+OJBU+92GE0EYMx0lybbFWGziWNulvaXaFXRjebCAHCFsgB9OlR
wNCZPJH8ivzWG1k2MbJuAFNIQLS2WpaB06nSQVE55jqqLYQK3l9V16NCwujzziJ98cmB
nWrtcArqO4kasBbrrcYVfX47SGQmMZWJB3sHxGSsRQU5mJa8H9OhbMsHj87uRbaVH4pb
8wwQ==
X-Gm-Message-State: APuU4Z90Eb+feu0FPVVyvyu/JHZpQZwba9abuWa3OvuHXPBsoesDLAtE
8YEFeRaGcx9b+DJiGpMs788GRt7zIvKGFBT9GXSj2tNi/gflZQ7arRDeKVAO2JgGtEwyuphbTAb
d+q2QUGMBToQdsgBlmkAJT16Zi5fTl8onezeVw8aI
X-Gm-Gg: AZFdTZfomwIk696B50OrZO5z1xAw0FHg4hX7fm3pWFuvHFF+PL96neUaTcIQBbovFS8
tAt74dKk9oJKol2IZrnJMaKqtIaSWrgeOAR9j1c9L3e03o1xYWXfyzyM3GxfoR6wo3MYlzf0TnN
zWuVCjIb3lVk8KKs/PijKYVvZQOgY3Z3Re1SVTYxyHPP52/7nTYB2q8N6fmUhpmrM5Y0RHtSvTG
WctFrPzAC9fASoe1MZI+ch4Ec3qSX9aASV5G4NSun0mdgK/1MEIVGE6iiJWYKXepIRWIrqcjm1f
ePVgjdSSE3JViYRSfHO+/79doPCNGwQbOlI6tavp7mF0ikTp9hL7ZYuglpgIhmctP6mVP1FTnwH
ywYaWKVbd7JDYuHpTtozQyLuDI7iyVeIf8Ind1uBKKTgvvWw8kDZVDi3qQKztkIhU6bzvWZgyPz
R6MjecIGDnNgsHuIL0CZi+agyJiceqw6zAJJu3UQYmBqx8uGfGMN+FQw19halmVjSfnQ8cSyT0V
TW7oKHbjw==
X-Received: by 2002:a05:6a20:5f96:b0:410:142:dde3 with SMTP id
adf61e73a8af0-4100142e405mr3220456637.65.1796065672811; Mon, 30 Nov 2026
11:07:52 -0800 (PST)
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
X-In-Reply-To: <20261130123028.516696-3-jedrzej.jagielski@intel.com>
X-Gm-Features: Aa3M54oAeQLnuBtvyVI7Hq6XGuhXW6it7Qec4wNIJf4MxeQtK4uJ7Nmll8csqpw
X-Cc: netdev@vger.kernel.org, anthony.l.nguyen@intel.com, kuba@kernel.org,
jiri@resnulli.us, edumazet@google.com, stable@vger.kernel.org,
Sashiko <sashiko-bot@kernel.org>