Skip to content

Commit

Permalink
arptables: use match, target and data copy_to_user helpers
Browse files Browse the repository at this point in the history
Convert arptables 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: Willem de Bruijn <willemb@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Willem de Bruijn authored and Pablo Neira Ayuso committed Jan 9, 2017
1 parent e47ddb2 commit 244b531
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions net/ipv4/netfilter/arp_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,17 @@ static int copy_entries_to_user(unsigned int total_size,
return PTR_ERR(counters);

loc_cpu_entry = private->entries;
/* ... then copy entire thing ... */
if (copy_to_user(userptr, loc_cpu_entry, total_size) != 0) {
ret = -EFAULT;
goto free_counters;
}

/* FIXME: use iterator macros --RR */
/* ... then go back and fix counters and names */
for (off = 0, num = 0; off < total_size; off += e->next_offset, num++){
const struct xt_entry_target *t;

e = (struct arpt_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
+ offsetof(struct arpt_entry, counters),
&counters[num],
Expand All @@ -698,11 +697,7 @@ static int copy_entries_to_user(unsigned int total_size,
}

t = arpt_get_target_c(e);
if (copy_to_user(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) {
if (xt_target_to_user(t, userptr + off + e->target_offset)) {
ret = -EFAULT;
goto free_counters;
}
Expand Down

0 comments on commit 244b531

Please sign in to comment.