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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:02:29 +0000 (14:02 -0700)
commit3355d641269f099906b995063fdadd6785488729
tree65c32c8673d8c31f6ed83d18377ea6278f4f0027
parent1f4ccda30391284201d732d0d360138efcfe01eb
netfilter: ebtables: compat: un-break 32bit setsockopt when no rules are present

[ Upstream commit 2035f3ff8eaa29cfb5c8e2160b0f6e85eeb21a95 ]

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
3f1e53abff84 ("netfilter: ebtables: don't attempt to allocate 0-sized compat array").

Fixes: 7d7d7e02111e9 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bridge/netfilter/ebtables.c