net: filter: fix upper BPF instruction limit
authorKees Cook <keescook@chromium.org>
Wed, 18 Jun 2014 22:34:57 +0000 (15:34 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 19 Jun 2014 00:04:15 +0000 (17:04 -0700)
The original checks (via sk_chk_filter) for instruction count uses ">",
not ">=", so changing this in sk_convert_filter has the potential to break
existing seccomp filters that used exactly BPF_MAXINSNS many instructions.

Fixes: bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: stable@vger.kernel.org # v3.15+
Acked-by: Daniel Borkmann <dborkman@redhat.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c

index 735fad89749630b71b2b64d6c82d59fec60a7c7f..a44e12cdde4c1ab1e28339cfb8c43a95905321cd 100644 (file)
@@ -840,7 +840,7 @@ int sk_convert_filter(struct sock_filter *prog, int len,
        BUILD_BUG_ON(BPF_MEMWORDS * sizeof(u32) > MAX_BPF_STACK);
        BUILD_BUG_ON(BPF_REG_FP + 1 != MAX_BPF_REG);
 
-       if (len <= 0 || len >= BPF_MAXINSNS)
+       if (len <= 0 || len > BPF_MAXINSNS)
                return -EINVAL;
 
        if (new_prog) {