]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[NET]: Validate socket filters against BPF_MAXINSNS in one spot.
authorDavid S. Miller <davem@sunset.davemloft.net>
Tue, 27 Dec 2005 21:57:59 +0000 (13:57 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Tue, 27 Dec 2005 21:57:59 +0000 (13:57 -0800)
Currently the checks are scattered all over and this leads
to inconsistencies and even cases where the check is not made.

Based upon a patch from Kris Katterjohn.

Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ppp_generic.c
net/core/filter.c

index 50430f79f8cf8190541e47495d625cae0cd7a765..1c6d328165bb066bd132b44c1fe4d4cbbbc0a096 100644 (file)
@@ -524,9 +524,6 @@ static int get_filter(void __user *arg, struct sock_filter **p)
        if (copy_from_user(&uprog, arg, sizeof(uprog)))
                return -EFAULT;
 
-       if (uprog.len > BPF_MAXINSNS)
-               return -EINVAL;
-
        if (!uprog.len) {
                *p = NULL;
                return 0;
index 2841bfce29d6a5d52433d0812362eb994f1f2765..3a10e0bc90e8a51ae4542ee4258f60f0d4509c64 100644 (file)
@@ -293,7 +293,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
        struct sock_filter *ftest;
        int pc;
 
-       if (((unsigned int)flen >= (~0U / sizeof(struct sock_filter))) || flen == 0)
+       if (flen == 0 || flen > BPF_MAXINSNS)
                return -EINVAL;
 
        /* check the filter code now */
@@ -360,7 +360,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
        int err;
 
        /* Make sure new filter is there and in the right amounts. */
-        if (fprog->filter == NULL || fprog->len > BPF_MAXINSNS)
+        if (fprog->filter == NULL)
                 return -EINVAL;
 
        fp = sock_kmalloc(sk, fsize+sizeof(*fp), GFP_KERNEL);