From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B9BD1F0092B; Sat, 5 Dec 2026 00:15:28 +0000 (UTC) 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== Subject: Re: [PATCH net-next 03/11] selftests: drv-net: tc_flower_police: Test that rules do not leak From: netdev-bot+sashiko@kernel.org To: mohsin.bashr@gmail.com 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 Date: Sat, 05 Dec 2026 00:15:27 +0000 Message-ID: <179642972779.3146.4146352416139305976@kernel.org> In-Reply-To: <20261204000521.3396802-4-mohsin.bashr@gmail.com> References: <20261204000521.3396802-4-mohsin.bashr@gmail.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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 ` 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 > Signed-off-by: Mohsin Bashir [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 " 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