* [PATCH net] fddi: validate skb length before parsing headers
@ 2026-06-07 11:24 Yizhou Zhao
2026-06-10 14:24 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yizhou Zhao @ 2026-06-07 11:24 UTC (permalink / raw)
To: netdev
Cc: Yizhou Zhao, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel, stable, Yuxiang Yang,
Ao Wang, Xuewei Feng, Qi Li, Ke Xu
fddi_type_trans() reads FDDI header fields from skb->data without first
checking that the received frame is long enough for those fields.
The destination address spans offsets 1-6 and the LLC dsap field is at
offset 13. For SNAP frames, fddi->hdr.llc_snap.ethertype is at offsets
19-20. A truncated 15-byte frame with dsap != 0xe0 therefore enters the
SNAP branch and reads the ethertype past the end of the frame.
KASAN reports this when such a frame is processed through a dummy FDDI
netdev that calls the real fddi_type_trans() on an exact kmalloc() copy
of the frame:
BUG: KASAN: slab-out-of-bounds in fddi_type_trans+0x385/0x3a0
Read of size 2 at addr ffff888009c6fe33
The buggy address is located 4 bytes to the right of
allocated 15-byte region [ffff888009c6fe20, ffff888009c6fe2f)
Reject short frames before reading the fields: require the minimum 802.2
header length before accessing dsap or daddr, and require the full SNAP
header length before reading the SNAP ethertype. Returning protocol 0
causes the malformed packet to be ignored by protocol handlers.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
Reported-by: Ao Wang <wangao@seu.edu.cn>
Reported-by: Xuewei Feng <fengxw06@126.com>
Reported-by: Qi Li <qli01@tsinghua.edu.cn>
Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
Assisted-by: GLM:GLM-5.1
Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
---
net/802/fddi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/802/fddi.c b/net/802/fddi.c
index 888379ae35ec..e26f4549e904 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -103,6 +103,9 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
skb->dev = dev;
skb_reset_mac_header(skb); /* point to frame control (FC) */
+ if (skb->len < FDDI_K_8022_HLEN)
+ return htons(0);
+
if(fddi->hdr.llc_8022_1.dsap==0xe0)
{
skb_pull(skb, FDDI_K_8022_HLEN-3);
@@ -110,6 +113,8 @@ __be16 fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
}
else
{
+ if (skb->len < FDDI_K_SNAP_HLEN)
+ return htons(0);
skb_pull(skb, FDDI_K_SNAP_HLEN); /* adjust for 21 byte header */
type=fddi->hdr.llc_snap.ethertype;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] fddi: validate skb length before parsing headers
2026-06-07 11:24 [PATCH net] fddi: validate skb length before parsing headers Yizhou Zhao
@ 2026-06-10 14:24 ` Simon Horman
2026-06-10 15:14 ` Jakub Kicinski
2026-06-10 15:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2026-06-10 14:24 UTC (permalink / raw)
To: Yizhou Zhao
Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel, stable, Yuxiang Yang, Ao Wang,
Xuewei Feng, Qi Li, Ke Xu
On Sun, Jun 07, 2026 at 07:24:04PM +0800, Yizhou Zhao wrote:
> fddi_type_trans() reads FDDI header fields from skb->data without first
> checking that the received frame is long enough for those fields.
>
> The destination address spans offsets 1-6 and the LLC dsap field is at
> offset 13. For SNAP frames, fddi->hdr.llc_snap.ethertype is at offsets
> 19-20. A truncated 15-byte frame with dsap != 0xe0 therefore enters the
> SNAP branch and reads the ethertype past the end of the frame.
>
> KASAN reports this when such a frame is processed through a dummy FDDI
> netdev that calls the real fddi_type_trans() on an exact kmalloc() copy
> of the frame:
>
> BUG: KASAN: slab-out-of-bounds in fddi_type_trans+0x385/0x3a0
> Read of size 2 at addr ffff888009c6fe33
> The buggy address is located 4 bytes to the right of
> allocated 15-byte region [ffff888009c6fe20, ffff888009c6fe2f)
>
> Reject short frames before reading the fields: require the minimum 802.2
> header length before accessing dsap or daddr, and require the full SNAP
> header length before reading the SNAP ethertype. Returning protocol 0
> causes the malformed packet to be ignored by protocol handlers.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Reported-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
> Reported-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
> Reported-by: Ao Wang <wangao@seu.edu.cn>
> Reported-by: Xuewei Feng <fengxw06@126.com>
> Reported-by: Qi Li <qli01@tsinghua.edu.cn>
> Reported-by: Ke Xu <xuke@tsinghua.edu.cn>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <zhaoyz24@mails.tsinghua.edu.cn>
I believe that drivers ensure that in practice packets hitting this path
are linear, so checking skb->len is sufficient to protect against OOB
reads.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] fddi: validate skb length before parsing headers
2026-06-07 11:24 [PATCH net] fddi: validate skb length before parsing headers Yizhou Zhao
2026-06-10 14:24 ` Simon Horman
@ 2026-06-10 15:14 ` Jakub Kicinski
2026-06-10 15:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-06-10 15:14 UTC (permalink / raw)
To: Yizhou Zhao
Cc: netdev, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
linux-kernel, stable, Yuxiang Yang, Ao Wang, Xuewei Feng, Qi Li,
Ke Xu
On Sun, 7 Jun 2026 19:24:04 +0800 Yizhou Zhao wrote:
> KASAN reports this when such a frame is processed through a dummy FDDI
> netdev that calls the real fddi_type_trans() on an exact kmalloc() copy
> of the frame:
>
> BUG: KASAN: slab-out-of-bounds in fddi_type_trans+0x385/0x3a0
> Read of size 2 at addr ffff888009c6fe33
> The buggy address is located 4 bytes to the right of
> allocated 15-byte region [ffff888009c6fe20, ffff888009c6fe2f)
>
> Reject short frames before reading the fields: require the minimum 802.2
> header length before accessing dsap or daddr, and require the full SNAP
> header length before reading the SNAP ethertype. Returning protocol 0
> causes the malformed packet to be ignored by protocol handlers.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
I'm stripping these, the problem seems entirely theoretical.
"I invented a fake driver and it makes the stack crash" is not serious.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH net] fddi: validate skb length before parsing headers
2026-06-07 11:24 [PATCH net] fddi: validate skb length before parsing headers Yizhou Zhao
2026-06-10 14:24 ` Simon Horman
2026-06-10 15:14 ` Jakub Kicinski
@ 2026-06-10 15:20 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-10 15:20 UTC (permalink / raw)
To: Yizhou Zhao
Cc: netdev, davem, edumazet, kuba, pabeni, horms, linux-kernel,
stable, yangyx22, wangao, fengxw06, qli01, xuke
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 7 Jun 2026 19:24:04 +0800 you wrote:
> fddi_type_trans() reads FDDI header fields from skb->data without first
> checking that the received frame is long enough for those fields.
>
> The destination address spans offsets 1-6 and the LLC dsap field is at
> offset 13. For SNAP frames, fddi->hdr.llc_snap.ethertype is at offsets
> 19-20. A truncated 15-byte frame with dsap != 0xe0 therefore enters the
> SNAP branch and reads the ethertype past the end of the frame.
>
> [...]
Here is the summary with links:
- [net] fddi: validate skb length before parsing headers
https://git.kernel.org/netdev/net-next/c/04fc949bd3aa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-10 15:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 11:24 [PATCH net] fddi: validate skb length before parsing headers Yizhou Zhao
2026-06-10 14:24 ` Simon Horman
2026-06-10 15:14 ` Jakub Kicinski
2026-06-10 15:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox