Commit edd8ae36 authored by Florian Westphal's avatar Florian Westphal Committed by Sasha Levin

netfilter: x_tables: xt_compat_match_from_user doesn't need a retval

[ Upstream commit 0188346f ]

Always returned 0.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent accd9c00
...@@ -425,7 +425,7 @@ void xt_compat_init_offsets(u_int8_t af, unsigned int number); ...@@ -425,7 +425,7 @@ void xt_compat_init_offsets(u_int8_t af, unsigned int number);
int xt_compat_calc_jump(u_int8_t af, unsigned int offset); int xt_compat_calc_jump(u_int8_t af, unsigned int offset);
int xt_compat_match_offset(const struct xt_match *match); int xt_compat_match_offset(const struct xt_match *match);
int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
unsigned int *size); unsigned int *size);
int xt_compat_match_to_user(const struct xt_entry_match *m, int xt_compat_match_to_user(const struct xt_entry_match *m,
void __user **dstptr, unsigned int *size); void __user **dstptr, unsigned int *size);
......
...@@ -1300,7 +1300,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e, ...@@ -1300,7 +1300,7 @@ check_compat_entry_size_and_hooks(struct compat_arpt_entry *e,
return ret; return ret;
} }
static int static void
compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr, compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
unsigned int *size, unsigned int *size,
struct xt_table_info *newinfo, unsigned char *base) struct xt_table_info *newinfo, unsigned char *base)
...@@ -1309,9 +1309,8 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr, ...@@ -1309,9 +1309,8 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
struct xt_target *target; struct xt_target *target;
struct arpt_entry *de; struct arpt_entry *de;
unsigned int origsize; unsigned int origsize;
int ret, h; int h;
ret = 0;
origsize = *size; origsize = *size;
de = (struct arpt_entry *)*dstptr; de = (struct arpt_entry *)*dstptr;
memcpy(de, e, sizeof(struct arpt_entry)); memcpy(de, e, sizeof(struct arpt_entry));
...@@ -1332,7 +1331,6 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr, ...@@ -1332,7 +1331,6 @@ compat_copy_entry_from_user(struct compat_arpt_entry *e, void **dstptr,
if ((unsigned char *)de - base < newinfo->underflow[h]) if ((unsigned char *)de - base < newinfo->underflow[h])
newinfo->underflow[h] -= origsize - *size; newinfo->underflow[h] -= origsize - *size;
} }
return ret;
} }
static int translate_compat_table(struct xt_table_info **pinfo, static int translate_compat_table(struct xt_table_info **pinfo,
...@@ -1411,16 +1409,11 @@ static int translate_compat_table(struct xt_table_info **pinfo, ...@@ -1411,16 +1409,11 @@ static int translate_compat_table(struct xt_table_info **pinfo,
entry1 = newinfo->entries[raw_smp_processor_id()]; entry1 = newinfo->entries[raw_smp_processor_id()];
pos = entry1; pos = entry1;
size = compatr->size; size = compatr->size;
xt_entry_foreach(iter0, entry0, compatr->size) { xt_entry_foreach(iter0, entry0, compatr->size)
ret = compat_copy_entry_from_user(iter0, &pos, &size, compat_copy_entry_from_user(iter0, &pos, &size,
newinfo, entry1); newinfo, entry1);
if (ret != 0)
break;
}
xt_compat_flush_offsets(NFPROTO_ARP); xt_compat_flush_offsets(NFPROTO_ARP);
xt_compat_unlock(NFPROTO_ARP); xt_compat_unlock(NFPROTO_ARP);
if (ret)
goto free_newinfo;
ret = -ELOOP; ret = -ELOOP;
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1)) if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))
......
...@@ -1565,7 +1565,7 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e, ...@@ -1565,7 +1565,7 @@ check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
return ret; return ret;
} }
static int static void
compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr, compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
unsigned int *size, unsigned int *size,
struct xt_table_info *newinfo, unsigned char *base) struct xt_table_info *newinfo, unsigned char *base)
...@@ -1574,10 +1574,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr, ...@@ -1574,10 +1574,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
struct xt_target *target; struct xt_target *target;
struct ipt_entry *de; struct ipt_entry *de;
unsigned int origsize; unsigned int origsize;
int ret, h; int h;
struct xt_entry_match *ematch; struct xt_entry_match *ematch;
ret = 0;
origsize = *size; origsize = *size;
de = (struct ipt_entry *)*dstptr; de = (struct ipt_entry *)*dstptr;
memcpy(de, e, sizeof(struct ipt_entry)); memcpy(de, e, sizeof(struct ipt_entry));
...@@ -1586,11 +1585,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr, ...@@ -1586,11 +1585,9 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
*dstptr += sizeof(struct ipt_entry); *dstptr += sizeof(struct ipt_entry);
*size += sizeof(struct ipt_entry) - sizeof(struct compat_ipt_entry); *size += sizeof(struct ipt_entry) - sizeof(struct compat_ipt_entry);
xt_ematch_foreach(ematch, e) { xt_ematch_foreach(ematch, e)
ret = xt_compat_match_from_user(ematch, dstptr, size); xt_compat_match_from_user(ematch, dstptr, size);
if (ret != 0)
return ret;
}
de->target_offset = e->target_offset - (origsize - *size); de->target_offset = e->target_offset - (origsize - *size);
t = compat_ipt_get_target(e); t = compat_ipt_get_target(e);
target = t->u.kernel.target; target = t->u.kernel.target;
...@@ -1603,7 +1600,6 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr, ...@@ -1603,7 +1600,6 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
if ((unsigned char *)de - base < newinfo->underflow[h]) if ((unsigned char *)de - base < newinfo->underflow[h])
newinfo->underflow[h] -= origsize - *size; newinfo->underflow[h] -= origsize - *size;
} }
return ret;
} }
static int static int
...@@ -1719,16 +1715,12 @@ translate_compat_table(struct net *net, ...@@ -1719,16 +1715,12 @@ translate_compat_table(struct net *net,
entry1 = newinfo->entries[raw_smp_processor_id()]; entry1 = newinfo->entries[raw_smp_processor_id()];
pos = entry1; pos = entry1;
size = compatr->size; size = compatr->size;
xt_entry_foreach(iter0, entry0, compatr->size) { xt_entry_foreach(iter0, entry0, compatr->size)
ret = compat_copy_entry_from_user(iter0, &pos, &size, compat_copy_entry_from_user(iter0, &pos, &size,
newinfo, entry1); newinfo, entry1);
if (ret != 0)
break;
}
xt_compat_flush_offsets(AF_INET); xt_compat_flush_offsets(AF_INET);
xt_compat_unlock(AF_INET); xt_compat_unlock(AF_INET);
if (ret)
goto free_newinfo;
ret = -ELOOP; ret = -ELOOP;
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1)) if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))
......
...@@ -1577,7 +1577,7 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e, ...@@ -1577,7 +1577,7 @@ check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
return ret; return ret;
} }
static int static void
compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr, compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
unsigned int *size, unsigned int *size,
struct xt_table_info *newinfo, unsigned char *base) struct xt_table_info *newinfo, unsigned char *base)
...@@ -1585,10 +1585,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr, ...@@ -1585,10 +1585,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
struct xt_entry_target *t; struct xt_entry_target *t;
struct ip6t_entry *de; struct ip6t_entry *de;
unsigned int origsize; unsigned int origsize;
int ret, h; int h;
struct xt_entry_match *ematch; struct xt_entry_match *ematch;
ret = 0;
origsize = *size; origsize = *size;
de = (struct ip6t_entry *)*dstptr; de = (struct ip6t_entry *)*dstptr;
memcpy(de, e, sizeof(struct ip6t_entry)); memcpy(de, e, sizeof(struct ip6t_entry));
...@@ -1597,11 +1596,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr, ...@@ -1597,11 +1596,9 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
*dstptr += sizeof(struct ip6t_entry); *dstptr += sizeof(struct ip6t_entry);
*size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry); *size += sizeof(struct ip6t_entry) - sizeof(struct compat_ip6t_entry);
xt_ematch_foreach(ematch, e) { xt_ematch_foreach(ematch, e)
ret = xt_compat_match_from_user(ematch, dstptr, size); xt_compat_match_from_user(ematch, dstptr, size);
if (ret != 0)
return ret;
}
de->target_offset = e->target_offset - (origsize - *size); de->target_offset = e->target_offset - (origsize - *size);
t = compat_ip6t_get_target(e); t = compat_ip6t_get_target(e);
xt_compat_target_from_user(t, dstptr, size); xt_compat_target_from_user(t, dstptr, size);
...@@ -1613,7 +1610,6 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr, ...@@ -1613,7 +1610,6 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
if ((unsigned char *)de - base < newinfo->underflow[h]) if ((unsigned char *)de - base < newinfo->underflow[h])
newinfo->underflow[h] -= origsize - *size; newinfo->underflow[h] -= origsize - *size;
} }
return ret;
} }
static int compat_check_entry(struct ip6t_entry *e, struct net *net, static int compat_check_entry(struct ip6t_entry *e, struct net *net,
...@@ -1728,17 +1724,12 @@ translate_compat_table(struct net *net, ...@@ -1728,17 +1724,12 @@ translate_compat_table(struct net *net,
} }
entry1 = newinfo->entries[raw_smp_processor_id()]; entry1 = newinfo->entries[raw_smp_processor_id()];
pos = entry1; pos = entry1;
size = compatr->size; xt_entry_foreach(iter0, entry0, compatr->size)
xt_entry_foreach(iter0, entry0, compatr->size) { compat_copy_entry_from_user(iter0, &pos, &size,
ret = compat_copy_entry_from_user(iter0, &pos, &size,
newinfo, entry1); newinfo, entry1);
if (ret != 0)
break;
}
xt_compat_flush_offsets(AF_INET6); xt_compat_flush_offsets(AF_INET6);
xt_compat_unlock(AF_INET6); xt_compat_unlock(AF_INET6);
if (ret)
goto free_newinfo;
ret = -ELOOP; ret = -ELOOP;
if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1)) if (!mark_source_chains(newinfo, compatr->valid_hooks, entry1))
......
...@@ -528,7 +528,7 @@ int xt_compat_match_offset(const struct xt_match *match) ...@@ -528,7 +528,7 @@ int xt_compat_match_offset(const struct xt_match *match)
} }
EXPORT_SYMBOL_GPL(xt_compat_match_offset); EXPORT_SYMBOL_GPL(xt_compat_match_offset);
int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, void xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
unsigned int *size) unsigned int *size)
{ {
const struct xt_match *match = m->u.kernel.match; const struct xt_match *match = m->u.kernel.match;
...@@ -551,7 +551,6 @@ int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr, ...@@ -551,7 +551,6 @@ int xt_compat_match_from_user(struct xt_entry_match *m, void **dstptr,
*size += off; *size += off;
*dstptr += msize; *dstptr += msize;
return 0;
} }
EXPORT_SYMBOL_GPL(xt_compat_match_from_user); EXPORT_SYMBOL_GPL(xt_compat_match_from_user);
......
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