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
[ Upstream commit bcc5364 ]

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 <andreyknvl@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
xairy authored and gregkh committed May 8, 2017
1 parent 3e77cac commit fe6fe14
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 @@ -3314,6 +3314,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 fe6fe14

Please sign in to comment.