aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSasha Levin <levinsasha928@gmail.com>2012-07-01 21:29:55 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-09 02:49:30 -0400
commit3da947b2693993d5f6138f005d2625e9387c9618 (patch)
treeaf7f831e5570f8081bd6d973a3aef7195f8a8967 /net
parent9e85a6f9dc231f3ed3c1dc1b12217505d970142a (diff)
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. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ieee802154/dgram.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 6fbb2ad7bb6d..16705611589a 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -230,6 +230,12 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
230 mtu = dev->mtu; 230 mtu = dev->mtu;
231 pr_debug("name = %s, mtu = %u\n", dev->name, mtu); 231 pr_debug("name = %s, mtu = %u\n", dev->name, mtu);
232 232
233 if (size > mtu) {
234 pr_debug("size = %Zu, mtu = %u\n", size, mtu);
235 err = -EINVAL;
236 goto out_dev;
237 }
238
233 hlen = LL_RESERVED_SPACE(dev); 239 hlen = LL_RESERVED_SPACE(dev);
234 tlen = dev->needed_tailroom; 240 tlen = dev->needed_tailroom;
235 skb = sock_alloc_send_skb(sk, hlen + tlen + size, 241 skb = sock_alloc_send_skb(sk, hlen + tlen + size,
@@ -258,12 +264,6 @@ static int dgram_sendmsg(struct kiocb *iocb, struct sock *sk,
258 if (err < 0) 264 if (err < 0)
259 goto out_skb; 265 goto out_skb;
260 266
261 if (size > mtu) {
262 pr_debug("size = %Zu, mtu = %u\n", size, mtu);
263 err = -EINVAL;
264 goto out_skb;
265 }
266
267 skb->dev = dev; 267 skb->dev = dev;
268 skb->sk = sk; 268 skb->sk = sk;
269 skb->protocol = htons(ETH_P_IEEE802154); 269 skb->protocol = htons(ETH_P_IEEE802154);