Re: [PATCH net] fddi: validate skb length before parsing headers

From: Simon Horman

Date: Wed Jun 10 2026 - 10:28:14 EST


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@xxxxxxxxxxxxxxx
> Reported-by: Yizhou Zhao <zhaoyz24@xxxxxxxxxxxxxxxxxxxxx>
> Reported-by: Yuxiang Yang <yangyx22@xxxxxxxxxxxxxxxxxxxxx>
> Reported-by: Ao Wang <wangao@xxxxxxxxxx>
> Reported-by: Xuewei Feng <fengxw06@xxxxxxx>
> Reported-by: Qi Li <qli01@xxxxxxxxxxxxxxx>
> Reported-by: Ke Xu <xuke@xxxxxxxxxxxxxxx>
> Assisted-by: GLM:GLM-5.1
> Signed-off-by: Yizhou Zhao <zhaoyz24@xxxxxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxx>