Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: hdlc_fr: Improve the initial checks when we receive an skb

1.
Change the skb->len check from "<= 4" to "< 4".
At first we only need to ensure a 4-byte header is present. We indeed
normally need the 5th byte, too, but it'd be more logical and cleaner
to check its existence when we actually need it.

2.
Add an fh->ea2 check to the initial checks in fr_rx. fh->ea2 == 1 means
the second address byte is the final address byte. We only support the
case where the address length is 2 bytes.

Cc: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Xie He and committed by
Jakub Kicinski
77124c44 efc79039

+1 -1
+1 -1
drivers/net/wan/hdlc_fr.c
··· 882 882 struct pvc_device *pvc; 883 883 struct net_device *dev; 884 884 885 - if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI) 885 + if (skb->len < 4 || fh->ea1 || !fh->ea2 || data[2] != FR_UI) 886 886 goto rx_error; 887 887 888 888 dlci = q922_to_dlci(skb->data);