Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linus Walleij" <linusw@kernel.org>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v10 2/4] net: dsa: tag_ks8995: Add the KS8995 tag handling
Date: Wed, 09 Sep 2026 09:39:27 +0000	[thread overview]
Message-ID: <20260909093928.276631F00ADF@smtp.kernel.org> (raw)
In-Reply-To: <20260908-ks8995-to-ksz8-v10-2-7379239eb65f@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Calling ilog2() with a zero value due to unvalidated portmask.
--

commit b59d7eee087d6b0879bef4bef35dc8e9d27f74bd
Author: Linus Walleij <linusw@kernel.org>

net: dsa: tag_ks8995: Add the KS8995 tag handling

This commit adds DSA tagging support for the Micrel KS8995 switch. It pushes
a special modified VLAN tag on transmit and processes it on receive to route
the frame to the appropriate user port.

> diff --git a/net/dsa/tag_ks8995.c b/net/dsa/tag_ks8995.c
> new file mode 100644
> index 0000000000000..9f6fdc1a9a076
> --- /dev/null
> +++ b/net/dsa/tag_ks8995.c
[ ... ]
> +static struct sk_buff *ks8995_rcv(struct sk_buff *skb, struct net_device *dev)
> +{
> +	int portmask;
> +	u16 etype;
[ ... ]
> +	etype = ntohs(*(__be16 *)dsa_etype_header_pos_rx(skb));
> +	if ((etype & KS8995M_STPID_STD) != ETH_P_8021Q) {
> +		netdev_dbg(dev, "%s: dropped ethertype 0x%04x\n",
> +			   __func__, etype);
> +		kfree_skb(skb);
> +		return NULL;
> +	}
[ ... ]
> +	portmask = FIELD_GET(KS8995M_STPID_PORTMASK, etype);
> +	netdev_dbg(dev, "%s: etype %04x portmask %04x (%d)\n",
> +		   __func__, etype, portmask, ilog2(portmask));
> +	skb->dev = dsa_conduit_find_user(dev, 0, ilog2(portmask));

[Severity: Medium]
Could this result in calling ilog2() with a zero value if a standard
802.1Q packet is received?

If the conduit interface receives a standard 802.1Q packet with ethertype
0x8100, the check (etype & KS8995M_STPID_STD) != ETH_P_8021Q passes because
0x8100 & 0xFFF0 is 0x8100.

The code then extracts portmask as 0x8100 & 0x000F, which is 0, and
unconditionally passes it to ilog2() in both netdev_dbg() and
dsa_conduit_find_user().

The ilog2() macro is explicitly documented as having undefined behavior when
passed 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-ks8995-to-ksz8-v10-0-7379239eb65f@kernel.org?part=2

  reply	other threads:[~2026-09-09  9:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08  9:38 [PATCH net-next v10 0/4] net: dsa: microchip: Add support for KSZ8995XA/KS8995XA Linus Walleij
2026-09-08  9:38 ` [PATCH net-next v10 1/4] dt-bindings: net: dsa: microchip: Add KSZ8995XA Linus Walleij
2026-09-09  9:39   ` sashiko-bot
2026-09-09 10:29     ` Linus Walleij
2026-09-09 12:39   ` netdev-bot+sashiko
2026-09-08  9:38 ` [PATCH net-next v10 2/4] net: dsa: tag_ks8995: Add the KS8995 tag handling Linus Walleij
2026-09-09  9:39   ` sashiko-bot [this message]
2026-09-09 10:47     ` Linus Walleij
2026-09-09 12:39   ` netdev-bot+sashiko
2026-09-08  9:38 ` [PATCH net-next v10 3/4] net: dsa: microchip: Support Microchip KSZ8995XA / KS8995XA Linus Walleij
2026-09-09  9:39   ` sashiko-bot
2026-09-09 10:51     ` Linus Walleij
2026-09-09 12:39   ` netdev-bot+sashiko
2026-09-08  9:38 ` [PATCH net-next v10 4/4] net: dsa: ks8995: Delete surplus driver Linus Walleij
2026-09-09 12:39   ` 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=20260909093928.276631F00ADF@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