فهرست منبع

ieee802154: add proper length checks to header creations

Have mac802154 header_ops.create fail with -EMSGSIZE if the length
passed will be too large to fit a frame. Since 6lowpan will ensure that
no packet payload will be too large, pass a length of 0 there. 802.15.4
dgram sockets will also return -EMSGSIZE on payloads larger than the
device MTU instead of -EINVAL.

Signed-off-by: Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Phoebe Buckheister 11 سال پیش
والد
کامیت
d1d7358e9f
3فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 1 1
      net/ieee802154/6lowpan_rtnl.c
  2. 1 1
      net/ieee802154/dgram.c
  3. 3 0
      net/mac802154/wpan.c

+ 1 - 1
net/ieee802154/6lowpan_rtnl.c

@@ -141,7 +141,7 @@ static int lowpan_header_create(struct sk_buff *skb,
 	}
 	}
 
 
 	return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
 	return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
-			type, (void *)&da, (void *)&sa, skb->len);
+			type, (void *)&da, (void *)&sa, 0);
 }
 }
 
 
 static int lowpan_give_skb_to_devices(struct sk_buff *skb,
 static int lowpan_give_skb_to_devices(struct sk_buff *skb,

+ 1 - 1
net/ieee802154/dgram.c

@@ -233,7 +233,7 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
 
 
 	if (size > mtu) {
 	if (size > mtu) {
 		pr_debug("size = %Zu, mtu = %u\n", size, mtu);
 		pr_debug("size = %Zu, mtu = %u\n", size, mtu);
-		err = -EINVAL;
+		err = -EMSGSIZE;
 		goto out_dev;
 		goto out_dev;
 	}
 	}
 
 

+ 3 - 0
net/mac802154/wpan.c

@@ -150,6 +150,9 @@ static int mac802154_header_create(struct sk_buff *skb,
 	skb_reset_mac_header(skb);
 	skb_reset_mac_header(skb);
 	skb->mac_len = hlen;
 	skb->mac_len = hlen;
 
 
+	if (hlen + len + 2 > dev->mtu)
+		return -EMSGSIZE;
+
 	return hlen;
 	return hlen;
 }
 }