net/packet: fix overflow in check for tp_reserve

When calculating po->tp_hdrlen + po->tp_reserve the result can overflow.

Fix by checking that tp_reserve <= INT_MAX on assign.

Change-Id: If3b5fd73bd440de2a1050644b71ef7430f09810f
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Git-repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Git-commit: bcc5364bdcfe131e6379363f089e7b4108d35b70
Signed-off-by: Dennis Cagle <dcagle@codeaurora.org>
This commit is contained in:
Andrey Konovalov 2017-03-29 16:11:22 +02:00 committed by Gerrit - the friendly Code Review server
parent dfb157d7a1
commit ad69147ee9

View file

@ -3602,6 +3602,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;
}