All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: wei.fang@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH v4 net-next 7/9] net: dsa: netc: add VLAN filter table and egress treatment management
Date: Wed, 10 Jun 2026 03:27:59 +0000	[thread overview]
Message-ID: <20260610032800.508131F00899@smtp.kernel.org> (raw)
In-Reply-To: <20260609032955.2066089-8-wei.fang@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] netc_port_update_vlan_egress_rule() incorrectly checks ett_eid instead of ect_eid before issuing an Egress Counter Table update, causing a hardware fault when ECT entries are exhausted.
--

commit daf8e6338d85480e82a01b715bb6d429fae4862d
Author: Wei Fang <wei.fang@nxp.com>

net: dsa: netc: add VLAN filter table and egress treatment management

Implement the DSA .port_vlan_add and .port_vlan_del operations to enable
VLAN-aware bridge offloading on the NETC switch.

> diff --git a/drivers/net/dsa/netc/netc_main.c b/drivers/net/dsa/netc/netc_main.c
> --- a/drivers/net/dsa/netc/netc_main.c
> +++ b/drivers/net/dsa/netc/netc_main.c

[ ... ]

> @@ -1025,6 +1054,385 @@ static void netc_switch_get_ip_revision(struct netc_switch *priv)
> +static int netc_port_update_vlan_egress_rule(struct netc_port *np,
> +					     struct netc_vlan_entry *entry)
> +{
> +	bool untagged = !!(entry->untagged_port_bitmap & BIT(np->dp->index));
> +	u32 num_ports = netc_num_available_ports(np->switch_priv);
> +	u32 ett_eid = le32_to_cpu(entry->cfge.et_eid);
> +	struct netc_switch *priv = np->switch_priv;
> +	u32 ect_eid = NTMP_NULL_ENTRY_ID;
> +	int err;

[ ... ]

> +	if (entry->ect_gid != NTMP_NULL_ENTRY_ID)
> +		/* Each ETT entry maps to an ECT entry if ect_gid is not NULL
> +		 * entry ID. The offset of the ECT entry corresponding to the
> +		 * port in the group is equal to ett_offset.
> +		 */
> +		ect_eid = entry->ect_gid * num_ports + np->ett_offset;
> +
> +	ett_eid += np->ett_offset;
> +	err = netc_update_ett_entry(priv, untagged, ett_eid, ect_eid);
> +	if (err) {
> +		dev_err(priv->dev,
> +			"Failed to update VLAN %u egress rule on port %d\n",
> +			entry->vid, np->dp->index);
> +		return err;
> +	}
> +
> +	if (ett_eid != NTMP_NULL_ENTRY_ID)
> +		ntmp_ect_update_entry(&priv->ntmp, ect_eid);

[Severity: High]
Should this check ect_eid instead of ett_eid before updating the counter
entry?

When Egress Counter Table (ECT) entries are exhausted, entry->ect_gid will
be NTMP_NULL_ENTRY_ID and ect_eid will keep its default value of
NTMP_NULL_ENTRY_ID. Because ett_eid was previously incremented by
np->ett_offset, it is guaranteed to be non-null here even if ECT entries
were exhausted.

As a result, ntmp_ect_update_entry() could be executed with
ect_eid = NTMP_NULL_ENTRY_ID, which would submit an out-of-bounds index
update to the switch hardware and cause a command bus error.

> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260609032955.2066089-1-wei.fang@oss.nxp.com?part=7

  reply	other threads:[~2026-06-10  3:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  3:29 [PATCH v4 net-next 0/9] net: dsa: netc: add bridge mode support wei.fang
2026-06-09  3:29 ` [PATCH v4 net-next 1/9] net: enetc: add interfaces to manage dynamic FDB entries wei.fang
2026-06-09  3:29 ` [PATCH v4 net-next 2/9] net: enetc: add "Update" and "Delete" operations to VLAN filter table wei.fang
2026-06-09  3:29 ` [PATCH v4 net-next 3/9] net: enetc: add interfaces to manage egress treatment table wei.fang
2026-06-09  3:29 ` [PATCH v4 net-next 4/9] net: enetc: add "Update" operation to the egress count table wei.fang
2026-06-09  3:29 ` [PATCH v4 net-next 5/9] net: dsa: netc: initialize the group bitmap of ETT and ECT wei.fang
2026-06-10  3:27   ` sashiko-bot
2026-06-10 10:13     ` Wei Fang (OSS)
2026-06-09  3:29 ` [PATCH v4 net-next 6/9] net: enetc: add helpers to set/clear table bitmap wei.fang
2026-06-10  3:27   ` sashiko-bot
2026-06-09  3:29 ` [PATCH v4 net-next 7/9] net: dsa: netc: add VLAN filter table and egress treatment management wei.fang
2026-06-10  3:27   ` sashiko-bot [this message]
2026-06-10 10:16     ` Wei Fang (OSS)
2026-06-09  3:29 ` [PATCH v4 net-next 8/9] net: dsa: netc: add bridge mode support wei.fang
2026-06-10  3:28   ` sashiko-bot
2026-06-10 10:30     ` Wei Fang (OSS)
2026-06-09  3:29 ` [PATCH v4 net-next 9/9] net: dsa: netc: implement dynamic FDB entry ageing wei.fang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260610032800.508131F00899@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wei.fang@oss.nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.