]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mac802154: fix mac header length check
authorAlexander Aring <aar@pengutronix.de>
Fri, 19 Feb 2016 08:59:11 +0000 (09:59 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 23 Feb 2016 19:29:39 +0000 (20:29 +0100)
I got report about that sometimes the WARN_ON occurs there which should
never happen. I came to the conclusion that the mac header is there but
inside the headroom of skb. The skb->len information doesn't contain the
information about the headroom length and skb->len is lesser than two.

We check now if the skb_mac_header pointer is set and the room between
mac header pointer and tail pointer.

Signed-off-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/mac802154.h

index da574bbdc33393fc927ba7297f7d67d0cf59b06e..2e3cdd2048d2bee45e9d248459b80db5a7d8658e 100644 (file)
@@ -247,8 +247,9 @@ struct ieee802154_ops {
  */
 static inline __le16 ieee802154_get_fc_from_skb(const struct sk_buff *skb)
 {
-       /* return some invalid fc on failure */
-       if (unlikely(skb->len < 2)) {
+       /* check if we can fc at skb_mac_header of sk buffer */
+       if (unlikely(!skb_mac_header_was_set(skb) ||
+                    (skb_tail_pointer(skb) - skb_mac_header(skb)) < 2)) {
                WARN_ON(1);
                return cpu_to_le16(0);
        }