Skip to content

Commit

Permalink
netfilter: ebtables: compat: un-break 32bit setsockopt when no rules …
Browse files Browse the repository at this point in the history
…are present

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

Fixes: 7d7d7e0 ("netfilter: compat: reject huge allocation requests")
Reported-by: Francesco Ruggeri <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
  • Loading branch information
Florian Westphal authored and ummakynes committed Jan 28, 2019
1 parent 53ab60b commit 2035f3f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/bridge/netfilter/ebtables.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2035f3f

Please sign in to comment.