|
@@ -1779,20 +1779,28 @@ static int compat_calc_entry(const struct ebt_entry *e,
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static int ebt_compat_init_offsets(unsigned int number)
|
|
|
|
|
+{
|
|
|
|
|
+ if (number > INT_MAX)
|
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
+
|
|
|
|
|
+ /* also count the base chain policies */
|
|
|
|
|
+ number += NF_BR_NUMHOOKS;
|
|
|
|
|
+
|
|
|
|
|
+ return xt_compat_init_offsets(NFPROTO_BRIDGE, number);
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
static int compat_table_info(const struct ebt_table_info *info,
|
|
static int compat_table_info(const struct ebt_table_info *info,
|
|
|
struct compat_ebt_replace *newinfo)
|
|
struct compat_ebt_replace *newinfo)
|
|
|
{
|
|
{
|
|
|
unsigned int size = info->entries_size;
|
|
unsigned int size = info->entries_size;
|
|
|
const void *entries = info->entries;
|
|
const void *entries = info->entries;
|
|
|
|
|
+ int ret;
|
|
|
|
|
|
|
|
newinfo->entries_size = size;
|
|
newinfo->entries_size = size;
|
|
|
- if (info->nentries) {
|
|
|
|
|
- int ret = xt_compat_init_offsets(NFPROTO_BRIDGE,
|
|
|
|
|
- info->nentries);
|
|
|
|
|
- if (ret)
|
|
|
|
|
- return ret;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ret = ebt_compat_init_offsets(info->nentries);
|
|
|
|
|
+ if (ret)
|
|
|
|
|
+ return ret;
|
|
|
|
|
|
|
|
return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
|
|
return EBT_ENTRY_ITERATE(entries, size, compat_calc_entry, info,
|
|
|
entries, newinfo);
|
|
entries, newinfo);
|
|
@@ -2241,11 +2249,9 @@ static int compat_do_replace(struct net *net, void __user *user,
|
|
|
|
|
|
|
|
xt_compat_lock(NFPROTO_BRIDGE);
|
|
xt_compat_lock(NFPROTO_BRIDGE);
|
|
|
|
|
|
|
|
- if (tmp.nentries) {
|
|
|
|
|
- ret = xt_compat_init_offsets(NFPROTO_BRIDGE, tmp.nentries);
|
|
|
|
|
- if (ret < 0)
|
|
|
|
|
- goto out_unlock;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ret = ebt_compat_init_offsets(tmp.nentries);
|
|
|
|
|
+ if (ret < 0)
|
|
|
|
|
+ goto out_unlock;
|
|
|
|
|
|
|
|
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)
|