Article View: linux.kernel.netdev
Article #24605Re: [PATCH net-next v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 12:25
Date: Mon, 30 Nov 2026 12:25
174 lines
13633 bytes
13633 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0
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).
- [High] This patch makes the REDIR-vs-TRAP decision once.
--
net: dsa: motorcomm: Reject isolated redirect targets
This patch checks the port isolation mask while parsing a flower redirect
action. If the redirect target is isolated, skip_sw rules are rejected.
Other rules are marked sw_assisting, and yt921x_acl_commit() then installs
them as TRAP instead of REDIR.
> diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
> index e3f057ed580f5..20edfd53b230d 100644
> --- a/drivers/net/dsa/motorcomm/tc.c
> +++ b/drivers/net/dsa/motorcomm/tc.c
[ ... ]
> @@ -1072,6 +1075,20 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
> goto fallback;
> }
>
> + /* Port isolation takes after REDIR judgment, but
> + * software delivers such frames.
> + */
> + if (pp->isolation_mask & BIT(to_dp->index)) {
> + if (cls->common.skip_sw) {
> + if (to_dp->index == port)
> + reason = "Redirect to self, which is not hairpinning";
> + else
> + reason = "Redirect target isolated, or not in the same bridge";
> + goto fallback;
> + }
> + ruleext->r.sw_assisting = true;
> + }
> +
[Severity: High]
Can sw_assisting go stale after the rule is installed? The isolation mask
is read only once, when yt921x_acl_rule_ext_parse_flow_action() parses the
rule, and the result is cached in aclrule->sw_assisting.
At this commit, yt921x_acl_commit() is called only from yt921x_acl_add()
and yt921x_acl_del(). Nothing rechecks the REDIR vs TRAP choice after
that.
Several paths in chip.c rewrite PORTn_ISOLATION and isolation_mask but
leave installed ACL rules alone:
drivers/net/dsa/motorcomm/chip.c:yt921x_userport_standalone() {
...
ctrl = ~dsa_cpu_ports(ds);
res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);
if (res)
return res;
pp->isolation_mask = ctrl;
...
}
drivers/net/dsa/motorcomm/chip.c:yt921x_isolate() {
...
priv->ports[i].isolation_mask |= mask;
...
}
drivers/net/dsa/motorcomm/chip.c:yt921x_bridge() {
...
res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port),
ctrl);
if (res)
return res;
pp->isolation_mask = ctrl;
...
}
For example, say swp1 and swp2 are both in br0, and this rule is added:
tc filter add dev swp1 ingress flower [skip_sw] \
action mirred egress redirect dev swp2
BIT(2) is clear in the mask for swp1, so the rule is installed as REDIR.
Then either swp1 or swp2 leaves br0, or BR_ISOLATED or BR_HAIRPIN_MODE
changes.
Isolation now blocks port 2, but the ACL entry still redirects to it.
Would those frames be dropped in hardware without software ever seeing
them? That is the case the commit message describes. For a skip_sw rule,
tc would also still report the rule as offloaded.
The reverse case looks wrong as well. A rule installed while the ports
were isolated stays trapped to the CPU after they become bridged.
Later commits in this series fix part of this:
"Reject bridge flags that break redirect rules" rejects flag changes that
would break skip_sw rules.
"Recompute redirect rules on bridge changes" adds yt921x_acl_recompute()
for non-skip_sw rules. Its own comment says skip_sw rules are not fixed up
on bridge leave, because port_bridge_leave() cannot fail. So a skip_sw
redirect installed while bridged would still drop traffic silently once
either port leaves the bridge.
yt921x_acl_recompute() also seems to derive the source port without
FIELD_GET():
src = ffs(aclrule->entries[0].key[1] &
YT921X_ACL_KEYb_SPORTS_M) - 1;
...
if (src != port && !(dsts & BIT(port)))
continue;
aclrule->sw_assisting =
!!(dsts & priv->ports[src].isolation_mask);
YT921X_ACL_KEYb_SPORTS_M is GENMASK(20, 10), so src would be the real
port plus 10. Two things follow from that:
- The src != port check would skip rules whose source is the changing
port. For example, after swp1 leaves the bridge, its redirect to swp2
is never recomputed.
- For rules that match through dsts, src can be as large as 20, but
priv->ports[] has only YT921X_PORT_NUM (11) entries. Does that read
priv->ports[] out of bounds?
If so, this problem would still be reachable at the end of the series,
for both skip_sw and non-skip_sw rules. Could isolation changes re-commit
the affected ACL actions?
> @@ -1301,8 +1318,20 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask)
> aclrule = aclblk->rules[binid];
>
> /* Write actions */
> - res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
> - aclrule ? aclrule->action : zeros);
> + if (!aclrule || !aclrule->sw_assisting) {
> + res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
> + aclrule ? aclrule->action : zeros);
> + } else {
[ ... ]
> diff --git a/drivers/net/dsa/motorcomm/tc.h b/drivers/net/dsa/motorcomm/tc.h
> index cc53f148d690f..81c29a8eec5ac 100644
> --- a/drivers/net/dsa/motorcomm/tc.h
> +++ b/drivers/net/dsa/motorcomm/tc.h
> @@ -349,7 +349,11 @@ struct yt921x_acl_rule {
> enum tc_setup_type type;
>
> u32 action[3];
> - bool sw_assisted;
> + bool sw_assisted:1;
> + /* not a TRAP rule, but installed as trapped as some conditions are not
> + * met
> + */
> + bool sw_assisting:1;
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129115556.1669188-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179604155555.3146.15300874955804709416@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374166-linux-kernel-netdev=dewy.ruReferences:
<20261129115556.1669188-4-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374166-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets Date: Mon, 30 Nov 2026 12:25:55 +0000 Organization: Usenet Network Message-ID: <179604155555.3146.15300874955804709416@kernel.org> References: <20261129115556.1669188-4-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1423082"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:SnOlGafc5yBooi4RJlglje2qCA8= sha256:4RtGkCKf6B6mK2P8oqts7rtgzugnIlQ7m2kIJDRn5yA= sha1:gjCthTBYYJK+zim0EDzepdu9EEM= sha256:XN/Rw6t9+n0uf3w5XOX9oBhP83sWKMU9jH+YLf/FYCU= 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 EAF4B125FDE; Mon, 30 Nov 2026 15:26:16 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 SLLuxHAMC9Gk; Mon, 30 Nov 2026 15:26:13 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374166-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id A7694125FE2; Mon, 30 Nov 2026 15:26:02 +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 E7BA32C3AA; Mon, 30 Nov 2026 12:25:57 +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=1796041557; b=MkY4cP0+6UXqagwxRC6weshkdGMiyYcmBsyc2nIx6CYa9+vmfAonxABSmkVJJA7l+33k jgU5wy7q+CDV7Ac+vYeNhukLl9whURlrX1T4sTyTzTHgAGsOeEiqGVB4mkG8Sk2wH43Ym AuxZrHQbxRPIb6FSjKQae1zypikvJWbIwcck/oNdrtGLxJquKRQr3oSqd4B+tAv3kqVqc QGzXWqwpbWfYwT0U+ImdKBbveTC3Cx205e559kpeVnRAmbsJIYppF9Ova0mSquAIXzy/I Hy1HMBWv1ddjr63H/Mf8QMV05iK6vxv9FOBnjCNu29CBXkvPHOcN7920ZKjwT7e2azw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041557; 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=BWwkCWEtPiPeksqUdpvyrpAt1fRgvF8SbHVFZYddrMk=; b=hGMyR3hMUk7+8OLPk+oK5rfDlcS30CImIw/ZL8Hj+ahJNmtT8h+akI8FMlPepJoeZP/X D7/c/cS0//iwHdUK0Qcy3VNZz2GJglcP8lSUkiItWOoYT8e9meSd3eJWQbSPpYRHDEqhr NgSXwmXnf93Cih8jmJRfXtu3zlTF0dRYsGFBX7bjcb2TXdSUtSPbXXjtQdcUYIozBYn5h q95A1BDDxiTImykWO+XgojsMIKAttfk4jK1trotTM3J0DIqbek8c/IiGy3xK9n3B8YGbw GwbabFn5gGBdxWIZy9KKmYg3JACtdsf3Z30vBbrCKfXzbXPVp86ewGcG2OY+tmDTD+Q== 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=kgr0P47T; 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 BC128606A31C; Mon, 30 Nov 2026 12:25:57 +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=kgr0P47T 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=1796041556; b=Y3JNUeo070bWKFLY6Swxq3Srkmwnarqf6N2IuHuYCUpwp+YfalPUAuPmHwi+9j3c9mJg MVUdUE09gl1iCVeyrsKMOVveNqX5vzOztB9frVyFBJzH/JeMMgkjdUyj3X1S8yzBBrXPc bgx9IzYxWf5TP8NLVrU5Jpv7Lq8Lhu+w5ZPDINhUbTyjg2Ix6QmHCpb4bUGTb7EPzcdCw rL9yJBFnW8SZc8aoc6wt6OAWhcWVa1rETUb7rCMZIEKXG13dS8AHQgdHblEQZSj+hwquT VRSji2JxuMbVPg+HeRgxqkt3V89Rny1l5QIQxqZDl+9mRU6G9I09a32Coayl+pSP97g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041556; 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=BWwkCWEtPiPeksqUdpvyrpAt1fRgvF8SbHVFZYddrMk=; b=KW4dRSqD5iLEymasFCn5HKfm3Tt+UnLNuUgNLYavun+F2H7Rl7HMGw2DyASTiVDvVOCP u2EbBl5D2HV8i14Bbv98XzBPSLMW7U7Czngb9i8O6gJVYAYuno0WQ02qnJk+UrCMJ2ZmL i4KLf1rsXcBGxUO4FI+ZMRQJHaeBFokZi+IfbZ4ocSZVKKG6vguiyRq5N7MO4tF7p6avF vY5XfFdV9Vs1QwS49ytRWGJjjkOUY3rxIF3Gn7uiowcB+m2gV5Yrn901eg44SycrwitPw 2DmP+8LTaHyLlb1/Ym/2upLRmClmXD7PE0sa/YHXS0CiKo3yS5G1LRTjK/5LIwDrYqg== 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=kgr0P47T; 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 DDD82606A32F for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 12:25:56 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0341B1F00896; Mon, 30 Nov 2026 12:25:55 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796041556; bh=BWwkCWEtPiPeksqUdpvyrpAt1fRgvF8SbHVFZYddrMk=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kgr0P47TVbT8Iw+iFb7Fr52MILoWUrLulC02deNO2ZHE00Q97QeExsgsSlGNKIBjK 2c6Djn/lly0b7/ztQJswKLnmsf49ABfIZpqV8Dld/iArxcQmYa9NOJ4t9N8GluuhKs JiMA3a2d0pLI6lLtZRL9jHM/5HThp+/NOYObYH5SIMeHjlUmLmjRhRGZFWSTXPf1Jx 5HE15Wgx+09O/Sbk62n5arfJrO3sX7UYOi+DHAXCJbWzht+4L7BDZfNEHd7CNyCkzM DdoH3MYErLcVpk13BUcd4Q5k4eybeuy2N/iAeiwoMzt97xzrlbZ8U505D3l1JNZNxs DpXDk38uZ7Sww== X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com X-In-Reply-To: <20261129115556.1669188-4-mmyangfl@gmail.com> X-sashiko-severity: High 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