Commit a4fa6c68 authored by Todd Seidelmann's avatar Todd Seidelmann Committed by Greg Kroah-Hartman

netfilter: ebtables: Fix argument order to ADD_COUNTER

[ Upstream commit f20faa06 ]

The ordering of arguments to the x_tables ADD_COUNTER macro
appears to be wrong in ebtables (cf. ip_tables.c, ip6_tables.c,
and arp_tables.c).

This causes data corruption in the ebtables userspace tools
because they get incorrect packet & byte counts from the kernel.

Fixes: d72133e6 ("netfilter: ebtables: use ADD_COUNTER macro")
Signed-off-by: default avatarTodd Seidelmann <tseidelmann@linode.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 634dd5a4
...@@ -225,7 +225,7 @@ unsigned int ebt_do_table(struct sk_buff *skb, ...@@ -225,7 +225,7 @@ unsigned int ebt_do_table(struct sk_buff *skb,
return NF_DROP; return NF_DROP;
} }
ADD_COUNTER(*(counter_base + i), 1, skb->len); ADD_COUNTER(*(counter_base + i), skb->len, 1);
/* these should only watch: not modify, nor tell us /* these should only watch: not modify, nor tell us
* what to do with the packet * what to do with the packet
...@@ -963,8 +963,8 @@ static void get_counters(const struct ebt_counter *oldcounters, ...@@ -963,8 +963,8 @@ static void get_counters(const struct ebt_counter *oldcounters,
continue; continue;
counter_base = COUNTER_BASE(oldcounters, nentries, cpu); counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
for (i = 0; i < nentries; i++) for (i = 0; i < nentries; i++)
ADD_COUNTER(counters[i], counter_base[i].pcnt, ADD_COUNTER(counters[i], counter_base[i].bcnt,
counter_base[i].bcnt); counter_base[i].pcnt);
} }
} }
...@@ -1289,7 +1289,7 @@ static int do_update_counters(struct net *net, const char *name, ...@@ -1289,7 +1289,7 @@ static int do_update_counters(struct net *net, const char *name,
/* we add to the counters of the first cpu */ /* we add to the counters of the first cpu */
for (i = 0; i < num_counters; i++) for (i = 0; i < num_counters; i++)
ADD_COUNTER(t->private->counters[i], tmp[i].pcnt, tmp[i].bcnt); ADD_COUNTER(t->private->counters[i], tmp[i].bcnt, tmp[i].pcnt);
write_unlock_bh(&t->lock); write_unlock_bh(&t->lock);
ret = 0; ret = 0;
......
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