Skip to contentSkip to conversation

ieee802154: verify packet size before trying to allocate it

PATCH In review Sasha Levin 2 participants 2 messages Jun 6, 2012 – Jun 7, 2012

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

PATCH 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. The maximum size of an IP packet seemed like the safest limit here.

---
 net/ieee802154/dgram.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/ieee802154/dgram.c +4 -0
index 6fbb2ad..cf5070b 100644
@@ -232,6 +232,10 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
 
 	hlen = LL_RESERVED_SPACE(dev);
 	tlen = dev->needed_tailroom;
+	if (hlen + tlen + size > USHRT_MAX) {
+		err = -EMSGSIZE;
+		goto out;
+	}
 	skb = sock_alloc_send_skb(sk, hlen + tlen + size,
 			msg->msg_flags & MSG_DONTWAIT,
 			&err);
Signature · 1 line
1.7.8.6
maintainer
#1 lore raw

From: Sasha Levin <[email protected]>
Date: Wed, 6 Jun 2012 23:32:02 +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. The maximum size of an IP packet seemed like the safest limit here.

This limit is arbitrary, I'm not applying a patch like this.

Use the actual limit, which is either the protocol limit or something like the device mtu.