aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2018-04-04 15:13:30 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2018-04-09 11:05:48 -0400
commit3f1e53abff84cf40b1adb3455d480dd295bf42e8 (patch)
tree02cc173cea03f00726b846f9f4e0ec559e34bdbc /net
parent5c64576a77894a50be80be0024bed27171b55989 (diff)
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>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/netfilter/ebtables.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 032e0fe45940..28a4c3490359 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -1825,13 +1825,14 @@ static int compat_table_info(const struct ebt_table_info *info,
1825{ 1825{
1826 unsigned int size = info->entries_size; 1826 unsigned int size = info->entries_size;
1827 const void *entries = info->entries; 1827 const void *entries = info->entries;
1828 int ret;
1829 1828
1830 newinfo->entries_size = size; 1829 newinfo->entries_size = size;
1831 1830 if (info->nentries) {
1832 ret = xt_compat_init_offsets(NFPROTO_BRIDGE, info->nentries); 1831 int ret = xt_compat_init_offsets(NFPROTO_BRIDGE,
1833 if (ret) 1832 info->nentries);
1834 return ret; 1833 if (ret)
1834 return ret;
1835 }
1835 1836
1836 return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info, 1837 return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
1837 entries, newinfo); 1838 entries, newinfo);