]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: ebtables: compat: un-break 32bit setsockopt when no rules are present
authorFlorian Westphal <fw@strlen.de>
Mon, 21 Jan 2019 20:54:36 +0000 (21:54 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 28 Jan 2019 09:49:43 +0000 (10:49 +0100)
Unlike ip(6)tables ebtables only counts user-defined chains.

The effect is that a 32bit ebtables binary on a 64bit kernel can do
'ebtables -N FOO' only after adding at least one rule, else the request
fails with -EINVAL.

This is a similar fix as done in
447de63b7be2 ("netfilter: ebtables: don't attempt to allocate 0-sized compat array").

Fixes: e236fe2567eb2 ("netfilter: compat: reject huge allocation requests")
Reported-by: Francesco Ruggeri <fruggeri@arista.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/ebtables.c

index 5e55cef0cec397485e74c90f561a162f2d3c6b43..6693e209efe809c86047abbfa019212e0e36c314 100644 (file)
@@ -2293,9 +2293,12 @@ static int compat_do_replace(struct net *net, void __user *user,
 
        xt_compat_lock(NFPROTO_BRIDGE);
 
-       ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
-       if (ret < 0)
-               goto out_unlock;
+       if (tmp.nentries) {
+               ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
+               if (ret < 0)
+                       goto out_unlock;
+       }
+
        ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
        if (ret < 0)
                goto out_unlock;