From: sashiko-bot@kernel.org
To: "Linus Walleij" <linusw@kernel.org>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v14 2/4] net: dsa: tag_ks8995: Add the KS8995 tag handling
Date: Tue, 15 Sep 2026 20:35:31 +0000 [thread overview]
Message-ID: <20260915203532.6631B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260914-ks8995-to-ksz8-v14-2-3d72692b3c97@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing SKB length validation before inserting VLAN tag causes out-of-bounds read and information leak.
- [Low] Missing explicit include of <linux/bitfield.h> for FIELD_PREP and FIELD_GET macros.
--
commit ac1156cbef4888a74fa57e39ccd4edb8d239ca42
Author: Linus Walleij <linusw@kernel.org>
net: dsa: tag_ks8995: Add the KS8995 tag handling
This commit introduces a DSA tag driver for the Micrel KS8995 switch,
adding support for ingress and egress tagging. The driver modifies an
802.1Q ethertype tag to include the target port mask and rate-limits
untagging errors.
> diff --git a/net/dsa/tag_ks8995.c b/net/dsa/tag_ks8995.c
> new file mode 100644
> index 0000000000000..d08166f0e9ad5
> --- /dev/null
> +++ b/net/dsa/tag_ks8995.c
> @@ -0,0 +1,173 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2026 Linus Walleij <linusw@kernel.org>
> + */
> +#include <linux/etherdevice.h>
> +#include <linux/log2.h>
> +#include <linux/list.h>
> +#include <linux/net.h>
> +#include <linux/slab.h>
> +
> +#include "tag.h"
[ ... ]
> +#define KS8995M_STPID_STD GENMASK(15, 4)
> +#define KS8995M_STPID_PORTMASK GENMASK(3, 0)
> +#define KS8995M_STPID(portmask) htons(ETH_P_8021Q | FIELD_PREP(KS8995M_STPID_PORTMASK, portmask))
[Severity: Low]
Does this file rely on an implicit include for the FIELD_PREP and FIELD_GET
macros?
Including <linux/bitfield.h> directly might prevent potential build failures
on configurations where the implicit include chain differs. The FIELD_GET
macro is also used later in ks8995_rcv().
> +static struct sk_buff *ks8995_xmit(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct vlan_ethhdr *hdr;
> + u16 portmask;
> +
> + /* Prepare the special KS8995 tags */
> + portmask = dsa_xmit_port_mask(skb, dev);
[ ... ]
> + /* Always add a distinct outer tag. The user port removes this field on
> + * egress, so reusing an existing 802.1Q tag would consume that VLAN tag.
> + */
> + skb = vlan_insert_tag(skb, KS8995M_STPID(portmask), 0);
[Severity: High]
Could this lead to an out-of-bounds read or write if a short packet is sent?
If a user with CAP_NET_RAW sends a very short packet (e.g., a 1-byte payload)
via an AF_PACKET raw socket, it might reach ndo_start_xmit without being
padded to 14 bytes because needed_tailroom is not set by the tagger.
When ks8995_xmit() calls vlan_insert_tag(), it operates under the assumption
that the MAC header is at least 14 bytes long. The vlan_insert_tag()
function uses memmove() to shift 12 bytes of the MAC header. If the skb
length is less than 12 bytes, this reads uninitialized heap memory into the
MAC header, which could then leak to the network wire.
Additionally, writing the 4-byte VLAN tag at offset 12 could write beyond
the allocated buffer size and corrupt skb_shared_info.
Should this path validate that skb->len is large enough before inserting the
VLAN tag, or ensure short packets are padded first?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-ks8995-to-ksz8-v14-0-3d72692b3c97@kernel.org?part=2
next prev parent reply other threads:[~2026-09-15 20:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 20:35 [PATCH net-next v14 0/4] net: dsa: microchip: Add support for KSZ8995XA/KS8995XA Linus Walleij
2026-09-14 20:35 ` [PATCH net-next v14 1/4] dt-bindings: net: dsa: microchip: Add KSZ8995XA Linus Walleij
2026-09-15 23:36 ` netdev-bot+sashiko
2026-09-14 20:35 ` [PATCH net-next v14 2/4] net: dsa: tag_ks8995: Add the KS8995 tag handling Linus Walleij
2026-09-15 20:35 ` sashiko-bot [this message]
2026-09-15 23:21 ` Linus Walleij
2026-09-14 20:35 ` [PATCH net-next v14 3/4] net: dsa: microchip: Support Microchip KSZ8995XA / KS8995XA Linus Walleij
2026-09-15 20:35 ` sashiko-bot
2026-09-15 23:36 ` netdev-bot+sashiko
2026-09-14 20:35 ` [PATCH net-next v14 4/4] net: dsa: ks8995: Delete surplus driver Linus Walleij
2026-09-15 23:36 ` netdev-bot+sashiko
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=20260915203532.6631B1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linusw@kernel.org \
--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