Skip to contentSkip to conversation

netfilter: ebtables: Fix argument order to ADD_COUNTER

PATCH In review Todd Seidelmann 2 participants 2 messages Aug 13, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: ebtables: Fix argument order to ADD_COUNTER

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.
---
 net/bridge/netfilter/ebtables.c | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)
net/bridge/netfilter/ebtables.c +0 -0
index c8177a8..4096d8a 100644
@@ -221,7 +221,7 @@ unsigned int ebt_do_table(struct sk_buff *skb,

             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
          * what to do with the packet
@@ -959,8 +959,8 @@ static void get_counters(const struct ebt_counter *oldcounters, continue;
         counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
         for (i = 0; i < nentries; i++)
-            ADD_COUNTER(counters[i], counter_base[i].pcnt,
-                    counter_base[i].bcnt);
+            ADD_COUNTER(counters[i], counter_base[i].bcnt,
+                    counter_base[i].pcnt);
     }
 }

@@ -1280,7 +1280,7 @@ static int do_update_counters(struct net *net, const char *name,

     /* we add to the counters of the first cpu */
     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);
     ret = 0;
--
1.8.3.1

maintainer
#1 lore raw
Quoted 6 lines · Todd Seidelmann

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.

Please resend with a 'Signed-off-by' tag and the 'Fixes:' tag that I provided when I reviewd this patch.

It will help stable maintainers to figure out which trees need this fix applied.