Skip to contentSkip to conversation

ieee802154: verify packet size before trying to allocate it

PATCH Applied Sasha Levin 2 participants 2 messages Jul 2, 2012 – Jul 9, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ieee802154: verify packet size before trying to allocate it

Currently when sending data over datagram, the send function will attempt to allocate any size passed on from the userspace.

We should make sure that this size is checked and limited. We'll limit it to the MTU of the device, which is checked later anyway.

---
 net/ieee802154/dgram.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
net/ieee802154/dgram.c +6 -6
index 6fbb2ad..1670561 100644
@@ -230,6 +230,12 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
 	mtu = dev->mtu;
 	pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
 
+	if (size > mtu) {
+		pr_debug("size = %Zu, mtu = %u\n", size, mtu);
+		err = -EINVAL;
+		goto out_dev;
+	}
+
 	hlen = LL_RESERVED_SPACE(dev);
 	tlen = dev->needed_tailroom;
 	skb = sock_alloc_send_skb(sk, hlen + tlen + size,
@@ -258,12 +264,6 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
 	if (err < 0)
 		goto out_skb;
 
-	if (size > mtu) {
-		pr_debug("size = %Zu, mtu = %u\n", size, mtu);
-		err = -EINVAL;
-		goto out_skb;
-	}
-
 	skb->dev = dev;
 	skb->sk  = sk;
 	skb->protocol = htons(ETH_P_IEEE802154);
Signature · 1 line
1.7.8.6
maintainer Applied
#1 lore raw

From: Sasha Levin <[email protected]>
Date: Mon, 2 Jul 2012 13:29:55 +0200

Quoted 7 lines

Currently when sending data over datagram, the send function will attempt to allocate any size passed on from the userspace.

We should make sure that this size is checked and limited. We'll limit it to the MTU of the device, which is checked later anyway.

Applied.