Skip to content

Commit

Permalink
ieee802154: verify packet size before trying to allocate it
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
sashalevin authored and davem330 committed Jul 9, 2012
1 parent 9e85a6f commit 3da947b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions net/ieee802154/dgram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3da947b

Please sign in to comment.