Commit f77bc5b2 authored by Willem de Bruijn's avatar Willem de Bruijn Committed by Pablo Neira Ayuso

iptables: use match, target and data copy_to_user helpers

Convert iptables to copying entries, matches and targets one by one,
using the xt_match_to_user and xt_target_to_user helper functions.
Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent f32815d2
...@@ -826,10 +826,6 @@ copy_entries_to_user(unsigned int total_size, ...@@ -826,10 +826,6 @@ copy_entries_to_user(unsigned int total_size,
return PTR_ERR(counters); return PTR_ERR(counters);
loc_cpu_entry = private->entries; loc_cpu_entry = private->entries;
if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) {
ret = -EFAULT;
goto free_counters;
}
/* FIXME: use iterator macros --RR */ /* FIXME: use iterator macros --RR */
/* ... then go back and fix counters and names */ /* ... then go back and fix counters and names */
...@@ -839,6 +835,10 @@ copy_entries_to_user(unsigned int total_size, ...@@ -839,6 +835,10 @@ copy_entries_to_user(unsigned int total_size,
const struct xt_entry_target *t; const struct xt_entry_target *t;
e = (struct ipt_entry *)(loc_cpu_entry + off); e = (struct ipt_entry *)(loc_cpu_entry + off);
if (copy_to_user(userptr + off, e, sizeof(*e))) {
ret = -EFAULT;
goto free_counters;
}
if (copy_to_user(userptr + off if (copy_to_user(userptr + off
+ offsetof(struct ipt_entry, counters), + offsetof(struct ipt_entry, counters),
&counters[num], &counters[num],
...@@ -852,23 +852,14 @@ copy_entries_to_user(unsigned int total_size, ...@@ -852,23 +852,14 @@ copy_entries_to_user(unsigned int total_size,
i += m->u.match_size) { i += m->u.match_size) {
m = (void *)e + i; m = (void *)e + i;
if (copy_to_user(userptr + off + i if (xt_match_to_user(m, userptr + off + i)) {
+ offsetof(struct xt_entry_match,
u.user.name),
m->u.kernel.match->name,
strlen(m->u.kernel.match->name)+1)
!= 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_counters; goto free_counters;
} }
} }
t = ipt_get_target_c(e); t = ipt_get_target_c(e);
if (copy_to_user(userptr + off + e->target_offset if (xt_target_to_user(t, userptr + off + e->target_offset)) {
+ offsetof(struct xt_entry_target,
u.user.name),
t->u.kernel.target->name,
strlen(t->u.kernel.target->name)+1) != 0) {
ret = -EFAULT; ret = -EFAULT;
goto free_counters; goto free_counters;
} }
......
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