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=1796041556; b=Y3JNUeo070bWKFLY6Swxq3Srkmwnarqf6N2IuHuYCUpwp+YfalPUAuPmHwi+9j3c9mJg MVUdUE09gl1iCVeyrsKMOVveNqX5vzOztB9frVyFBJzH/JeMMgkjdUyj3X1S8yzBBrXPc bgx9IzYxWf5TP8NLVrU5Jpv7Lq8Lhu+w5ZPDINhUbTyjg2Ix6QmHCpb4bUGTb7EPzcdCw rL9yJBFnW8SZc8aoc6wt6OAWhcWVa1rETUb7rCMZIEKXG13dS8AHQgdHblEQZSj+hwquT VRSji2JxuMbVPg+HeRgxqkt3V89Rny1l5QIQxqZDl+9mRU6G9I09a32Coayl+pSP97g== 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== 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 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 ; Mon, 30 Nov 2026 12:25:56 +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=kgr0P47T Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0341B1F00896; Mon, 30 Nov 2026 12:25:55 +0000 (UTC) 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== Subject: Re: [PATCH net-next v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets From: netdev-bot+sashiko@kernel.org To: mmyangfl@gmail.com Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com Date: Mon, 30 Nov 2026 12:25:55 +0000 Message-ID: <179604155555.3146.15300874955804709416@kernel.org> In-Reply-To: <20261129115556.1669188-4-mmyangfl@gmail.com> References: <20261129115556.1669188-4-mmyangfl@gmail.com> X-sashiko-severity: High 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 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