Article View: linux.kernel.netdev
Article #27182Re: [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 00:15
Date: Sat, 05 Dec 2026 00:15
163 lines
14442 bytes
14442 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] police_no_leak() is not built to catch the leak the commit
message gives as its motivation.
- [Medium] _scale_fill() runs up to 1025 synchronous skip_sw hardware
offloads in one `tc -batch` through cmd(), and police_no_leak()…
- [Low] The commit is authored by Mohsin Bashir (From:), but the tag
block lists `Signed-off-by: Jakub Kicinski <kuba@kernel.org>` before…
--
selftests: drv-net: tc_flower_police: Test that rules do not leak
This adds a police_no_leak test to tc_flower_police.py. The test adds
skip_sw flower rules with a police action until the device refuses one.
It then flushes the rules and checks that the device takes the same
number of rules again.
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
[Severity: Low]
This isn't a bug, but is a Co-developed-by: tag missing here?
Mohsin Bashir is the author of the patch, but Jakub has the first
Signed-off-by:. Documentation/process/submitting-patches.rst says the
first SoB signals primary authorship. It also says a co-author is
recorded with Co-developed-by:, immediately followed by that person's
Signed-off-by:.
Should there be a "Co-developed-by: Jakub Kicinski <kuba@kernel.org>"
line above his SoB, or is the From: author wrong? The other patches in
the series seem to have the same pattern.
> diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> index 86d26314decf7..b03a00ad0c0ba 100755
> --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
> +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py
[ ... ]
> +def _scale_fill(cfg, count, force=False):
> + with tempfile.NamedTemporaryFile("w") as tmp:
> + for i in range(count):
> + tmp.write(f"filter add dev {cfg.ifname} ingress pref 100 "
> + f"handle {i + 1} {_ctrl_rule(cfg, i)} skip_sw "
> + f"{_police(100)}\n")
> + tmp.flush()
> + res = cmd(f"tc {'-force ' if force else ''}-batch {tmp.name}",
> + fail=False)
[Severity: Medium]
Can this run past the default cmd() timeout on slower devices?
This single tc process does up to 1025 synchronous skip_sw offloads, and
cmd() keeps its default timeout=20. cmd._process_terminate() in
tools/testing/selftests/net/lib/py/utils.py does this:
stdout, stderr = self.proc.communicate(timeout=timeout)
When the timeout expires, this raises subprocess.TimeoutExpired. cmd
doesn't catch it, and the tc child is not killed. If a device averages
more than about 19ms per offload (slow firmware mailbox, debug kernel),
ksft_run() reports a failure with a raw traceback instead of a clear
result.
The NamedTemporaryFile is then unlinked, but tc still has it open. So tc
keeps adding rules while the deferred "tc filter del" and the clsact
teardown run.
The flush in police_no_leak() has the same problem:
cmd(f"tc filter del dev {cfg.ifname} ingress")
fl_destroy()->fl_hw_destroy_filter() calls into the driver synchronously
for each of the roughly 1000 filters. The refill of full + 1 rules has
the same cost.
A later patch in the series handles subprocess.TimeoutExpired in
_iperf3_flows(), but _scale_fill() and the flush are still the same at
the end of the series. Would it make sense to scale the timeout with the
rule count here?
> + if res.ret and "Command failed" not in res.stderr:
> + raise KsftFailEx(f"tc -batch failed: {res.stderr.strip()}")
> + return _count_filters(cfg)
[ ... ]
> +def police_no_leak(cfg):
[ ... ]
> + full = _scale_fill(cfg, limit)
> + if not full:
> + raise KsftSkipEx("Rule not offloaded")
> + if full == limit:
> + raise KsftSkipEx(f"Device accepted all {limit} rules, cannot fill it")
> + ksft_pr(f"Device full after {full} rules")
> +
> + cmd(f"tc filter del dev {cfg.ifname} ingress")
> + left = _count_filters(cfg)
> + if left:
> + raise KsftFailEx(f"{left} rules left after the flush")
> + if not _wait_police_freed():
> + raise KsftFailEx("Police actions still present after 5 s")
> + refill = _scale_fill(cfg, full + 1, force=True)
> + ksft_eq(refill, full, "Rules taken after the flush")
[Severity: Medium]
Will this check catch a leak on a failed install, as the commit message
says it should?
The commit message says:
Drivers often reserve a policer or a classifier entry before they know
whether a rule can be installed. Missing the release on rule removal or
on a failed install leaks the entry
A failed install can only leak a resource X that it managed to reserve.
That means X still had room after full rules, so cap_X >= full + 1.
After the flush, at least cap_X - n units of X are free, where n is the
number of failed installs in the first fill. The refill only drops below
full if n > cap_X - full.
The test does not control n. The first fill runs without -force, so tc
-batch stops at the first error it reports. tc groups the filter add
lines into netlink batches of up to 128 messages per sendmsg.
netlink_rcv_skb() keeps processing every message in the batch after an
error:
err = cb(skb, nlh, &extack);
...
if (nlh->nlmsg_flags & NLM_F_ACK || err)
netlink_ack(skb, nlh, err, &extack);
So n is the rest of the batch that holds rule full + 1, anywhere from 1
to 127. For full = 1023 or 1024 there is exactly one failed install.
With only one failure, a leaked policer or ID that is not the limiting
resource never changes the refill count, so a leaking driver would pass.
The refill also ends with one failed install, but nothing checks the
device after it.
Could the test repeat the refused install on purpose so the leaked units
add up until they become the limit? For example, it could retry the
rejected rule many times, or run the first fill with -force over all
1025 attempts. If not, should the commit message be limited to leaks on
rule removal?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204000521.3396802-1-mohsin.bashr%40gmail.com
Technical Details
Message-ID:
<179642972779.3146.4146352416139305976@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377758-linux-kernel-netdev=dewy.ruReferences:
<20261204000521.3396802-4-mohsin.bashr@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mi.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377758-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak Date: Sat, 05 Dec 2026 00:15:27 +0000 Organization: Usenet Network Message-ID: <179642972779.3146.4146352416139305976@kernel.org> References: <20261204000521.3396802-4-mohsin.bashr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2913570"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:wta5DQvUz97rG4YTXcVHHIKgYVU= sha256:Wd6X3pOhEWq26b2Qq2HNyLPmtp7BYKePdThIM/hX/ss= sha1:1jd6gUp1LKytCH73vjUvkl4jPVw= sha256:E8tq4wx8F6YMSbF0qUR1yE706iU5WhQQyH+gJhrFqd0= 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 B1B97117D2C; Sat, 5 Dec 2026 03:15:50 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.642 X-Spam-Status: No, score=-3.642 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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=kernel.org 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 V08KQ6pGcpRP; Sat, 5 Dec 2026 03:15:47 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377758-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 5DB7F117D23; Sat, 5 Dec 2026 03:15:35 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 5AF68278FB; Sat, 5 Dec 2026 00:15:32 +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=1796429730; b=J/m0o9XRX5djTeWnSYLcu6MzOl5aj9MJVo3nWxXB4bKT5px138ZL12VVdol9Y+/E+zyT eEsMtAobhQWoHXqAUD8SU1Kxw5yGdzlJbUs4F04/ZrnuiPRZTUq5LXplUflYyDl+vMSIy dCCC26Iwa0xtLgDXJXuGB9YqfMadNU05rBZftspO2E9C3dc/JuZRVVoPmZugLjBJoQWu2 iay/GqvOzB3ZPmR3dAfB9bVtusddOwhkbO0v7oAppdLLWSKFOQ+jbxple7pVAfaDOn5v+ U7rxza6dhnf0EbAv9lo2AqQKTURVP04k8IuF4iuHCCfGAPagfSMqa0oa3BkJuv3E6UA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796429730; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=FEUAMbW5Z2VrwPEUjIYvARvi0tiToVyAXxQP7dx1Guk=; b=XcWsI1fRCu6wFBpjVNp8PXvNKdYvYFXiB4EjYL/GtrQ16EHyQJDFgwzKUtgM3En0U/kb N7W39yeidwBoBaS0xQVlb+IQOErTkGd20FWZkPXkZrh1+MOCfz427tIx7cm9RO/rTxLjM lNaiwm79UhMm4fzVcmeC89xO+tcK8I5SR7Mxlmga7sYnYhSltVft7XlEFUEnCUAhG4rzH /LlEwe9d8XRtxf4CoWwkF4pC/FYredlyv92wFSv9rIjAFVKfxMMA6XVyvNM9V3lyvUlrF Qbrrs3ViONlsCBmjBoPPDQyQcD+MiFHyFPUrHtq17ElpmUMpqc49aGIy7iBEeOWSBkA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBz+Oxk7; 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 EA11E606A33F; Sat, 5 Dec 2026 00:15:29 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBz+Oxk7 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796429729; b=c1QgkJLPKsrFQaS8ZgGUdKBlNGkJ365eemioxGF/CjeYmnJ0scxYOLybK81wkD4rA56t zcZhkr5mbYdJ+TA99nKgBjoNylHpafJ5rif9XULBQI4e3Pm/Lf0/soSgXAwlgX/xkpQPW vy+OY77Hv5v5ju8qrGpnti6PSewOQHuat/tmKzkC2cGHFyMQF646bNVa9sBHrF+doYFoy zfjKv/HBvZQsDftC5I4kwE+u4xTqgQ/0pxtoUp8Ek+sS2NxtAaSqcOOnoPhsawuMjSWLa UN+6I5eEbEdGZO7VOSvZqZdVcpyKgyi9xPSIJ40s/aZ6n499nlkDkKN6ghYSibwJxTA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796429729; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=FEUAMbW5Z2VrwPEUjIYvARvi0tiToVyAXxQP7dx1Guk=; b=Y1ROGFsykX/PhTA4vauKEbjZkdFgUjtrTloPQ9yewrZW6EP/CTHg10sGOnXEsfVB0G7m DIk3M6/AIgaQuNq3Fs+7GCnLZG+GKtiUpHMvGWjCvqV0IDEiAuKLF8n8+Deia/3Ji368v sa0pCQQ7RDq2RwQvOEgkpwW2tg74GK+fHETBy3KuLFd6zWULybvVHucf1eARGcTJwa8LC KGp1qonM/r+aYhhTEyKFX9/umyHEErOUY0dnQTLf0yHcOu2CIvxBZ9RwighkzXOb9HQ/q uNJ18iZmRQ9lVIwFJjfpNwBe2pT61NIo9n+iTePIzOYo31x3vSeN3ZJMi0IZPM0EUug== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SBz+Oxk7; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19956606A68E; Sat, 5 Dec 2026 00:15:28 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B9BD1F0092B; Sat, 5 Dec 2026 00:15:28 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796429728; bh=FEUAMbW5Z2VrwPEUjIYvARvi0tiToVyAXxQP7dx1Guk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SBz+Oxk79nfgSvYSEOiFbhCn23l7sT7RmgD6C4k6p0tbcHv3vCBLiRFEInewJHs+P z2tJH0FzH8qSAxuQ2Rsojidpk5xeVcxQOQ8H9Y+g7Djzy8nf5Je+M7oxuHXLAp4uNY PJGiHZdNSBCW0TuvtxHTZd5qTbs2vU8OE/eT62SA6U6ws+BhcgNR6KrYtz+8eQ5RSF BWHyAEwvt+Hg7hqw0d1lV+WtXnVej5e170rDnW/cKEEQN4ZnKB2fd10xsfM7uoWnwN DgkoJdXGniCKo52P0itUTtsZRVK/toDPY+8KHfXaDF3+jZ8ud/bxvAvDpKEQLnHghg fwyFtJDJjintA== X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org X-In-Reply-To: <20261204000521.3396802-4-mohsin.bashr@gmail.com> X-sashiko-severity: Medium 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