From: sashiko-bot@kernel.org
To: "Minghuan Lian" <minghuan.lian@nxp.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
krzk+dt@kernel.org
Subject: Re: [PATCH net-next 2/4] net: dsa: tag_hms: Add HMS tag protocol
Date: Sun, 10 May 2026 09:10:56 +0000 [thread overview]
Message-ID: <20260510091056.91967C2BCB8@smtp.kernel.org> (raw)
In-Reply-To: <20260509090632.2959553-3-minghuan.lian@nxp.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The `buf` pointer in `hms_rcv_meta_cmd()` becomes a dangling pointer if `skb_linearize()` reallocates the SKB.
- [High] Incorrect length calculation in `hms_rcv_meta_cmd()` leads to an integer underflow when invoking the switch driver's meta command handler.
- [High] Returning `NULL` after `__vlan_hwaccel_push_inside()` fails in `hms_imprecise_xmit()` causes a double free in the caller.
- [Medium] The Kconfig symbol NET_DSA_TAG_HMS selects a non-existent symbol NET_DSA_TAG_8021Q.
--
commit 5802d819bc05556c0d9f828794cc67145ff4496a
Author: Minghuan Lian <minghuan.lian@nxp.com>
net: dsa: tag_hms: Add HMS tag protocol
This commit adds a DSA tagger for NXP Heterogeneous Multi-SoC (HMS) switches.
It supports both tag_8021q based transmit and receive handling for regular
data traffic, and an HMS meta frame format for link-local and control traffic.
> diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
> --- a/net/dsa/Kconfig
> +++ b/net/dsa/Kconfig
> @@ -211,4 +211,13 @@ config NET_DSA_TAG_YT921X
> Say Y or M if you want to enable support for tagging frames for
> Motorcomm YT921x switches.
>
> +config NET_DSA_TAG_HMS
> + tristate "Tag driver for NXP Heterogeneous Multi-SoC switches"
> + select NET_DSA_TAG_8021Q
Does the NET_DSA_TAG_8021Q config symbol exist? Looking through the tree, it
appears tag_8021q.c is compiled unconditionally as part of dsa_core-y rather
than having its own Kconfig symbol. Selecting a non-existent symbol can lead
to unmet dependency warnings or silent build failures.
> + help
> + Say Y or M if you want to enable support for tagging frames for
> + NXP Heterogeneous Multi-SoC switch family. This driver uses a
[ ... ]
> diff --git a/net/dsa/tag_hms.c b/net/dsa/tag_hms.c
> new file mode 100644
> --- /dev/null
> +++ b/net/dsa/tag_hms.c
[ ... ]
> +static struct sk_buff *hms_imprecise_xmit(struct sk_buff *skb,
> + struct net_device *netdev)
> +{
> + struct dsa_port *dp = dsa_user_to_port(netdev);
> + unsigned int bridge_num = dsa_port_bridge_num_get(dp);
> + struct net_device *br = dsa_port_bridge_dev_get(dp);
> + u16 tx_vid;
[ ... ]
> + if (unlikely(skb_vlan_tag_present(skb))) {
> + skb = __vlan_hwaccel_push_inside(skb);
> + if (!skb) {
> + WARN_ONCE(1, "Failed to push VLAN tag to payload!\n");
> + return NULL;
Could returning NULL here lead to a double free?
If __vlan_hwaccel_push_inside() fails, it consumes and frees the original skb.
However, returning NULL back up to the DSA core (dsa_user_xmit) usually
signals that the tagger did not consume the skb, which leads the DSA core to
call kfree_skb() on the original pointer again.
> + }
> + }
> +
> + return dsa_8021q_xmit(skb, netdev, hms_xmit_tpid(dp), tx_vid);
> +}
[ ... ]
> +static struct sk_buff *hms_rcv_meta_cmd(struct sk_buff *skb, u16 rx_header)
> +{
> + u8 *buf = dsa_etype_header_pos_rx(skb) + HMS_HEADER_LEN;
> + int switch_id = HMS_RX_HEADER_SWITCH_ID(rx_header);
> + int source_port = HMS_RX_HEADER_PORT_ID(rx_header);
> + struct hms_tagger_data *tagger_data;
> + struct net_device *master = skb->dev;
> + struct dsa_port *cpu_dp;
> + struct dsa_switch *ds;
> +
> + cpu_dp = master->dsa_ptr;
> + ds = dsa_switch_find(cpu_dp->dst->index, switch_id);
> + if (!ds) {
> + net_err_ratelimited("%s: cannot find switch id %d\n",
> + master->name, switch_id);
> + return NULL;
> + }
> +
> + tagger_data = ds->tagger_data;
> + if (!tagger_data->meta_cmd_handler)
> + return NULL;
> +
> + if (skb_is_nonlinear(skb))
> + if (skb_linearize(skb))
> + return NULL;
If skb_linearize() reallocates the data buffer to make it contiguous, does the
buf pointer become dangling? It was initialized before the linearization and
might now point to freed memory.
> +
> + tagger_data->meta_cmd_handler(ds, source_port, buf,
> + skb->len - HMS_HEADER_LEN - 2 * ETH_ALEN);
Is this length calculation correct for the receive path?
Since the MAC header has usually already been pulled from the skb by the time
we reach the tagger, skb->len should simply be the payload size. Subtracting
an additional 2 * ETH_ALEN might cause an integer underflow if the metadata
payload is small, resulting in a huge size_t value being passed to the driver
callback.
> +
> + /* Discard the meta frame */
> + return NULL;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260509090632.2959553-1-minghuan.lian@nxp.com?part=2
next prev parent reply other threads:[~2026-05-10 9:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-09 9:06 [PATCH net-next 0/4] net: dsa: Add NXP i.MX RT1180 NETC switch support Minghuan Lian
2026-05-09 9:06 ` [PATCH net-next 1/4] dt-bindings: net: dsa: add NXP i.MX RT1180 NETC switch Minghuan Lian
2026-05-15 7:29 ` Krzysztof Kozlowski
2026-05-09 9:06 ` [PATCH net-next 2/4] net: dsa: tag_hms: Add HMS tag protocol Minghuan Lian
2026-05-10 9:10 ` sashiko-bot [this message]
2026-05-09 9:06 ` [PATCH net-next 3/4] net: dsa: hms: Add NXP i.MX RT1180 NETC switch driver Minghuan Lian
2026-05-10 9:10 ` sashiko-bot
2026-05-09 9:06 ` [PATCH net-next 4/4] net: dsa: hms: Add ethtool statistics support Minghuan Lian
2026-05-10 9:10 ` sashiko-bot
2026-05-13 1:39 ` [PATCH net-next 0/4] net: dsa: Add NXP i.MX RT1180 NETC switch support Jakub Kicinski
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=20260510091056.91967C2BCB8@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=minghuan.lian@nxp.com \
--cc=robh@kernel.org \
--cc=sashiko@lists.linux.dev \
/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.