netfilter: xtables: add scheduling opportunity in get_counters
authorFlorian Westphal <fw@strlen.de>
Fri, 1 Sep 2017 20:41:03 +0000 (22:41 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 8 Sep 2017 16:55:27 +0000 (18:55 +0200)
There are reports about spurious softlockups during iptables-restore, a
backtrace i saw points at get_counters -- it uses a sequence lock and also
has unbounded restart loop.

Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c

index e044571..9e2770f 100644 (file)
@@ -629,6 +629,7 @@ static void get_counters(const struct xt_table_info *t,
 
                        ADD_COUNTER(counters[i], bcnt, pcnt);
                        ++i;
+                       cond_resched();
                }
        }
 }
index 576cba2..39286e5 100644 (file)
@@ -776,6 +776,7 @@ get_counters(const struct xt_table_info *t,
 
                        ADD_COUNTER(counters[i], bcnt, pcnt);
                        ++i; /* macro does multi eval of i */
+                       cond_resched();
                }
        }
 }
index 54b1e75..01bd3ee 100644 (file)
@@ -795,6 +795,7 @@ get_counters(const struct xt_table_info *t,
 
                        ADD_COUNTER(counters[i], bcnt, pcnt);
                        ++i;
+                       cond_resched();
                }
        }
 }