net: add validation for the socket syscall protocol argument
[pandora-kernel.git] / net / ipv4 / af_inet.c
index 5d228de..e2ab968 100644 (file)
@@ -279,6 +279,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
        int try_loading_module = 0;
        int err;
 
+       if (protocol < 0 || protocol >= IPPROTO_MAX)
+               return -EINVAL;
+
        if (unlikely(!inet_ehash_secret))
                if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
                        build_ehash_secret();