netfilter: ebtables: don't attempt to allocate 0-sized compat array
authorFlorian Westphal <fw@strlen.de>
Wed, 4 Apr 2018 19:13:30 +0000 (21:13 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 9 Apr 2018 15:05:48 +0000 (17:05 +0200)
commit3f1e53abff84cf40b1adb3455d480dd295bf42e8
tree02cc173cea03f00726b846f9f4e0ec559e34bdbc
parent5c64576a77894a50be80be0024bed27171b55989
netfilter: ebtables: don't attempt to allocate 0-sized compat array

Dmitry reports 32bit ebtables on 64bit kernel got broken by
a recent change that returns -EINVAL when ruleset has no entries.

ebtables however only counts user-defined chains, so for the
initial table nentries will be 0.

Don't try to allocate the compat array in this case, as no user
defined rules exist no rule will need 64bit translation.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: 7d7d7e02111e9 ("netfilter: compat: reject huge allocation requests")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/bridge/netfilter/ebtables.c