Commit 5a6351ee authored by Eric Dumazet's avatar Eric Dumazet Committed by Pablo Neira Ayuso

netfilter: fix ebtables compat support

commit 255d0dc3 (netfilter: x_table: speedup compat operations)
made ebtables not working anymore.

1) xt_compat_calc_jump() is not an exact match lookup
2) compat_table_info() has a typo in xt_compat_init_offsets() call
3) compat_do_replace() misses a xt_compat_init_offsets() call
Reported-by: default avatardann frazier <dannf@dannf.org>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
parent 315c34da
...@@ -1766,7 +1766,7 @@ static int compat_table_info(const struct ebt_table_info *info, ...@@ -1766,7 +1766,7 @@ static int compat_table_info(const struct ebt_table_info *info,
newinfo->entries_size = size; newinfo->entries_size = size;
xt_compat_init_offsets(AF_INET, info->nentries); xt_compat_init_offsets(NFPROTO_BRIDGE, info->nentries);
return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info, return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
entries, newinfo); entries, newinfo);
} }
...@@ -2240,6 +2240,7 @@ static int compat_do_replace(struct net *net, void __user *user, ...@@ -2240,6 +2240,7 @@ static int compat_do_replace(struct net *net, void __user *user,
xt_compat_lock(NFPROTO_BRIDGE); xt_compat_lock(NFPROTO_BRIDGE);
xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state); ret = compat_copy_entries(entries_tmp, tmp.entries_size, &state);
if (ret < 0) if (ret < 0)
goto out_unlock; goto out_unlock;
......
...@@ -455,6 +455,7 @@ void xt_compat_flush_offsets(u_int8_t af) ...@@ -455,6 +455,7 @@ void xt_compat_flush_offsets(u_int8_t af)
vfree(xt[af].compat_tab); vfree(xt[af].compat_tab);
xt[af].compat_tab = NULL; xt[af].compat_tab = NULL;
xt[af].number = 0; xt[af].number = 0;
xt[af].cur = 0;
} }
} }
EXPORT_SYMBOL_GPL(xt_compat_flush_offsets); EXPORT_SYMBOL_GPL(xt_compat_flush_offsets);
...@@ -473,8 +474,7 @@ int xt_compat_calc_jump(u_int8_t af, unsigned int offset) ...@@ -473,8 +474,7 @@ int xt_compat_calc_jump(u_int8_t af, unsigned int offset)
else else
return mid ? tmp[mid - 1].delta : 0; return mid ? tmp[mid - 1].delta : 0;
} }
WARN_ON_ONCE(1); return left ? tmp[left - 1].delta : 0;
return 0;
} }
EXPORT_SYMBOL_GPL(xt_compat_calc_jump); EXPORT_SYMBOL_GPL(xt_compat_calc_jump);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment