From: sashiko-bot@kernel.org
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v6 1/9] net: dsa: add tag driver for LAN9645X
Date: Sat, 30 May 2026 00:50:11 +0000 [thread overview]
Message-ID: <20260530005012.373D51F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260527-dsa_lan9645x_switch_driver_base-v6-1-4d409ae64f3c@microchip.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The driver fails to handle hardware-accelerated VLAN tags on transmit, leading to dropped VLAN tags.
- [High] The driver ignores the return values of bridge VLAN functions, leading to the use of uninitialized stack variables.
- [High] The tag driver leaks the socket buffer (`skb`) when frame padding fails.
--
commit 2c0a796d85ea905a1a209fed6a3f2589d5f8409a
Author: Jens Emil Schulz Østergaard <jensemil.schulzostergaard@microchip.com>
net: dsa: add tag driver for LAN9645X
Add tag driver for LAN9645x using a front port as CPU port. This mode
is called an NPI port in the datasheet.
> diff --git a/net/dsa/tag_lan9645x.c b/net/dsa/tag_lan9645x.c
> new file mode 100644
> index 0000000000000..0b639228215e3
> --- /dev/null
> +++ b/net/dsa/tag_lan9645x.c
[ ... ]
> +static void lan9645x_xmit_get_vlan_info(struct sk_buff *skb,
> + struct net_device *br,
> + u32 *vlan_tci, u32 *tag_type)
> +{
> + struct vlan_ethhdr *hdr;
> + u16 proto, tci;
> +
> + if (!br || !br_vlan_enabled(br)) {
> + *vlan_tci = 0;
> + *tag_type = LAN9645X_IFH_TAG_TYPE_C;
> + return;
> + }
> +
> + hdr = (struct vlan_ethhdr *)skb_mac_header(skb);
> + br_vlan_get_proto(br, &proto);
> +
> + if (skb_headlen(skb) >= VLAN_ETH_HLEN &&
> + ntohs(hdr->h_vlan_proto) == proto) {
> + vlan_remove_tag(skb, &tci);
> + *vlan_tci = tci;
[Severity: High]
Does this code handle hardware-accelerated VLAN tags on transmit?
If the networking stack passes the VLAN tag out-of-band via skb->vlan_tci,
the payload ethertype will be the inner protocol (e.g., IPv4) and the check
above evaluates to false. This ignores the intended VLAN tag.
Could this be changed to use skb_vlan_tag_present(skb) and
skb_vlan_tag_get(skb)?
> + } else {
> + rcu_read_lock();
> + br_vlan_get_pvid_rcu(br, &tci);
[Severity: High]
Does this ignore the return value of br_vlan_get_pvid_rcu()?
If the port has no default PVID configured, it can return an error code,
leaving tci uninitialized. The uninitialized tci is then used to populate
the hardware frame header, potentially injecting stack garbage into the
packet's VLAN TCI.
> + rcu_read_unlock();
> + *vlan_tci = tci;
> + }
> +
> + *tag_type = (proto != ETH_P_8021Q) ? LAN9645X_IFH_TAG_TYPE_S :
> + LAN9645X_IFH_TAG_TYPE_C;
> +}
> +
> +static struct sk_buff *lan9645x_xmit(struct sk_buff *skb,
> + struct net_device *ndev)
> +{
> + struct dsa_port *dp = dsa_user_to_port(ndev);
> + struct dsa_switch *ds = dp->ds;
> + u32 cpu_port = ds->num_ports;
> + u32 vlan_tci, tag_type;
> + u32 qos_class;
> + void *ifh;
> +
> + lan9645x_xmit_get_vlan_info(skb, dsa_port_bridge_dev_get(dp), &vlan_tci,
> + &tag_type);
> +
> + /* We need to make sure frame has the proper size after IFH is stripped
> + * by hw.
> + */
> + if (__skb_put_padto(skb, ETH_ZLEN, false))
> + return NULL;
[Severity: High]
Will this leak the socket buffer when padding fails?
__skb_put_padto() is called with free_on_error set to false. If padding
fails, this returns NULL. The DSA core transmit routine assumes a NULL return
from a tagger's transmit function means the tagger has freed or consumed
the skb, so the core won't free it. This permanently leaks the skb.
Should this use true for free_on_error instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260527-dsa_lan9645x_switch_driver_base-v6-0-4d409ae64f3c@microchip.com?part=1
next prev parent reply other threads:[~2026-05-30 0:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 14:49 [PATCH net-next v6 0/9] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 1/9] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-27 15:39 ` Jonas Gorski
2026-05-28 10:45 ` Jens Emil Schulz Ostergaard
2026-05-30 0:50 ` sashiko-bot [this message]
2026-05-27 14:49 ` [PATCH net-next v6 2/9] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 3/9] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-05-27 14:49 ` [PATCH net-next v6 4/9] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 5/9] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 6/9] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 7/9] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 8/9] net: dsa: lan9645x: add mdb management Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
2026-05-27 14:49 ` [PATCH net-next v6 9/9] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-05-30 0:50 ` sashiko-bot
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=20260530005012.373D51F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox