Skip to content

Commit

Permalink
net/packet: fix overflow in check for tp_reserve
Browse files Browse the repository at this point in the history
When calculating po->tp_hdrlen + po->tp_reserve the result can overflow.

Fix by checking that tp_reserve <= INT_MAX on assign.

Signed-off-by: Andrey Konovalov <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
xairy authored and davem330 committed Mar 30, 2017
1 parent 8f8d28e commit bcc5364
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,8 @@ packet_setsockopt(struct socket *sock, int level, int optname, char __user *optv
return -EBUSY;
if (copy_from_user(&val, optval, sizeof(val)))
return -EFAULT;
if (val > INT_MAX)
return -EINVAL;
po->tp_reserve = val;
return 0;
}
Expand Down

0 comments on commit bcc5364

Please sign in to comment.