From: Doruk Tan Ozturk <doruk@0sec.ai>
To: Vladimir Oltean <olteanv@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Woojung Huh <woojung.huh@microchip.com>,
Nick Child <nnac123@linux.ibm.com>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org,
Sabrina Dubroca <sd@queasysnail.net>,
Arun Ramadoss <arun.ramadoss@microchip.com>,
UNGLinuxDriver@microchip.com,
Michael Ellerman <mpe@ellerman.id.au>,
Doruk Tan Ozturk <doruk@0sec.ai>,
stable@vger.kernel.org
Subject: [PATCH net 2/3] net: dsa: tag_ksz: don't read an unset MAC header in lan937x_xmit()
Date: Mon, 13 Jul 2026 21:40:09 +0200 [thread overview]
Message-ID: <20260713194010.54642-3-doruk@0sec.ai> (raw)
In-Reply-To: <20260713194010.54642-1-doruk@0sec.ai>
lan937x_xmit() reads the Ethernet header via eth_hdr(skb) to test the
destination address. The sibling xmit paths in this file (ksz8795_xmit,
ksz9477_xmit, ksz9893_xmit) already use skb_eth_hdr(); lan937x_xmit() is
the lone hold-out.
On the AF_PACKET SOCK_RAW + PACKET_QDISC_BYPASS transmit path the skb
reaches ndo_start_xmit() with the MAC header unset, so eth_hdr(skb)
resolves to skb->head + (u16)~0 and the read is out of bounds.
On the TX path the L2 header is at skb->data, so use skb_eth_hdr(), as
done for the same class by
commit f5089008f90c ("macsec: don't read an unset MAC header in macsec_encrypt()")
and commit 96cc4b69581d ("macvlan: do not assume mac_header is set in macvlan_broadcast()").
Fixes: 092f875131dc ("net: dsa: tag_ksz: add tag handling for Microchip LAN937x")
Cc: stable@vger.kernel.org
Found by 0sec automated security-research tooling (https://0sec.ai).
Assisted-by: 0sec:claude-opus-4-8
Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai>
---
net/dsa/tag_ksz.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c
index 67fa89f102e0..4f74336ae396 100644
--- a/net/dsa/tag_ksz.c
+++ b/net/dsa/tag_ksz.c
@@ -430,7 +430,7 @@ static struct sk_buff *lan937x_xmit(struct sk_buff *skb,
u16 queue_mapping = skb_get_queue_mapping(skb);
u8 prio = netdev_txq_to_tc(dev, queue_mapping);
struct dsa_port *dp = dsa_user_to_port(dev);
- const struct ethhdr *hdr = eth_hdr(skb);
+ const struct ethhdr *hdr = skb_eth_hdr(skb);
__be16 *tag;
u16 val;
--
2.43.0
next prev parent reply other threads:[~2026-07-13 19:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 19:40 [PATCH net 0/3] net: don't read an unset MAC header on the raw/qdisc-bypass TX path Doruk Tan Ozturk
2026-07-13 19:40 ` [PATCH net 1/3] net: dsa: tag_ocelot_8021q: don't read an unset MAC header on transmit Doruk Tan Ozturk
2026-07-13 20:04 ` Vladimir Oltean
2026-07-13 21:12 ` Doruk (0sec)
2026-07-13 21:37 ` Vladimir Oltean
2026-07-13 19:40 ` Doruk Tan Ozturk [this message]
2026-07-13 19:40 ` [PATCH net 3/3] ibmveth: " Doruk Tan Ozturk
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=20260713194010.54642-3-doruk@0sec.ai \
--to=doruk@0sec.ai \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew+netdev@lunn.ch \
--cc=arun.ramadoss@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=nnac123@linux.ibm.com \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
--cc=stable@vger.kernel.org \
--cc=woojung.huh@microchip.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox