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=1796041558; b=4yNU0zCAvaAnel6nmSXhIQLPXGozmXuUxeYJoFmevK2YCvo5XA93N33aNcCBOfkSAh9i pDPLrOOrUQfJ3pJhBQX3qkmJuRdgzbk2uT0vU6kqfdi571NnXWykEuo1Mrht0khjV+EAZ gu4LDoFliTqKofkesd0bnHgHJCma0WP+FoRCDXlPvffwvyxlxpMn87sH5Q7u/7zavO4Ql xn9aukSJP0O51rCVSLpc6UdwjVQUPYKvtzvhTV480DA9lh304qf8gLQdfXMPAqJvpApxA Lk/33FIJ93cITZ6aO7eRBh0nxkLqbNiY1ZkXzeMXuG7goSJW4hjfhbjhiMAZP9sdW3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796041558; 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=lyncOSeYB5OV68nVCZT1DFdFt/lpUnWWqVx1WQcVv1Q=; b=GFwLKkXJrdxXf/ilSfHQ2al49UwFjiAXmxbxj0ZGvMrqkdDrYmTCU+eIQYHfZfqR7/x/ T+OGlGqxfeDfHetdKOzRHna4fJK7RLgbm2MSMnUAJuDxIOD/jNl5lelEn5oBlF5i7Wno4 aA80atlblQh/vjgU1zc9gc3k9+EOd/V1QaW5zcOam4DUvc4+KwSrHcYErjh8mJf+RYtv4 5g/NcAPpI1am4GWQ4QosvaH9bk4x9ffVyAzN3+DHLQqF0nOEzBFr5U8tpMa/9nDVdQOJU 99VJqr3wLuHmx4IWprFEwSNY+/CLwerogN/EqzeBDTCVPOE9v6PZr7BDJxz/SbRnZhw== 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=j+4ooDVD; 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 03567606A329 for ; Mon, 30 Nov 2026 12:25:57 +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=j+4ooDVD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09CA51F00896; Mon, 30 Nov 2026 12:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796041557; bh=lyncOSeYB5OV68nVCZT1DFdFt/lpUnWWqVx1WQcVv1Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=j+4ooDVD1T7iHkRKXpvllY7nmp4mHEMctaB+NuUukDVSjvDdrzofhKmuMTaLvuLl0 1nhKnsblUuxCgeSzLVrot/sBYYI8HS6VNEPNYl13Ne5d4yN7mIuSQF8JtnWGcr+aFk OWUh3BcwlaKTHmBuKIVk6NO4H32Y1dJxebiUQQhV68MyofSnvH/5B9hvA90ML1GY0X Sm6bBObT4B9v0wvkiXpHQHJpNs2UXLIvQWTbdcIU80aDPxlzmkaov1Ci204Ci3096i KNaUEzHR+J9PmGXnJKuMyOWQZIyEAaFOKKXyikqJJKa5afc7S4D7XlWoFBsQuYlp+S j6uhtogRcJJFw== Subject: Re: [PATCH net-next v2 4/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes 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:56 +0000 Message-ID: <179604155661.3146.6089853869175513173@kernel.org> In-Reply-To: <20261129115556.1669188-5-mmyangfl@gmail.com> References: <20261129115556.1669188-5-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 2 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · 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). - [High] yt921x_acl_recompute() in drivers/net/dsa/motorcomm/tc.c gets the rule's source port wrong. - [Low] net: dsa: motorcomm: redundant ACL commits in yt921x_acl_recompute() -- net: dsa: motorcomm: Recompute redirect rules on bridge changes This adds yt921x_acl_recompute(), which re-evaluates non-skip_sw redirect rules after bridge join, leave and flag changes rewrite the port isolation masks. It is called from yt921x_bridge_flags(), yt921x_dsa_port_bridge_join() and yt921x_dsa_port_bridge_leave(). > diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c > index 20edfd53b230d..146db2a37c268 100644 > --- a/drivers/net/dsa/motorcomm/tc.c > +++ b/drivers/net/dsa/motorcomm/tc.c > @@ -1394,6 +1394,56 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask) [ ... ] > +int yt921x_acl_recompute(struct yt921x_priv *priv, int port) > +{ [ ... ] > + src = ffs(aclrule->entries[0].key[1] & > + YT921X_ACL_KEYb_SPORTS_M) - 1; > + dsts = FIELD_GET(YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M, > + action[2]); > + if (src != port && !(dsts & BIT(port))) > + continue; > + > + aclrule->sw_assisting = > + !!(dsts & priv->ports[src].isolation_mask); ^^^^^^^^^^^^^^^^^ [Severity: High] Can this read past the end of priv->ports[]? The source port field is not shifted down before ffs(), and tc.h has: #define YT921X_ACL_KEYb_SPORTS_M GENMASK(20, 10) #define YT921X_ACL_KEYb_SPORTn(port) BIT((port) + 10) So a rule on port p gives src = p + 10. For p >= 1 that is 11..20, but ports[] only has YT921X_PORT_NUM (11) entries. For p == 0 it reads the isolation_mask of port 10 instead. The other decoders of this field, yt921x_acl_find(), yt921x_acl_add() and yt921x_acl_del(), all use FIELD_GET(YT921X_ACL_KEYb_SPORTS_M, ...). Should this be something like: src = ffs(FIELD_GET(YT921X_ACL_KEYb_SPORTS_M, aclrule->entries[0].key[1])) - 1; The same offset also breaks the filter above. Because src != port is almost always true, rules sourced on the port whose bridge state changed are skipped unless they also redirect to that port. As an example, take a non-skip_sw flower rule on port 1 that redirects to port 2. A bridge join or leave on port 2, or a BR_ISOLATED or BR_HAIRPIN_MODE change there, calls yt921x_acl_recompute(priv, 2). The rule passes the dsts & BIT(2) check, and priv->ports[11] is read. That value then decides whether yt921x_acl_commit() writes a REDIR or a TRAP action to YT921X_ACLn_ACT. The later patch in this series, "net: dsa: motorcomm: Reject bridge flags that break redirect rules", does not touch yt921x_acl_recompute(), so the problem is still there at the end of the series. > + entid = YT921X_ACL_ENT_PER_BLK * blkid + i; > + res = yt921x_acl_commit(priv, entid, aclrule->mask); > + if (res) > + return res; > + } > + } > + > + return 0; > +} [Severity: Low] This calls yt921x_acl_commit() for every rule that passes the filter, whether or not the newly computed sw_assisting value differs from the one already programmed. Each commit rewrites the 96-bit action, the key and mask of every entry in the rule, and the block KEEP, ENTRY and CMD registers. All of that goes over MDIO while reg_lock is held in the bridge join, leave and flags paths. FLOW_ACTION_DROP rules also get past the action check here. yt921x_acl_rule_ext_parse_flow_action() encodes them as YT921X_ACL_ACTc_FWD_EN | YT921X_ACL_ACTc_FWD_REDIR with an empty DPORTS field. For those rules dsts is 0, so sw_assisting always comes out false and the commit just writes back the action that is already there. Once src is decoded correctly, every non-skip_sw drop rule sourced on the port would be reprogrammed on each bridge change. The same applies to redirect rules whose destinations are not affected by the isolation change. Nothing breaks functionally, but would it make sense to skip rules with dsts == 0? yt921x_acl_commit() could also be called only when sw_assisting actually flips, for example by computing the new value into a local, comparing it with aclrule->sw_assisting and continuing if they match. Or is the unconditional rewrite intended to resync the hardware after an earlier failed commit? sw_assisting is updated before yt921x_acl_commit() runs, so after a failure the software state and the hardware can disagree. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129115556.1669188-1-mmyangfl%40gmail.com