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 e04457198f939aa2805ebb86f3bfd61a496d363f..9e2770fd00be5eda1a633893c42b59378ab52f17 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 576cba2b57e92753671c67b6df88e2cc67374cde..39286e543ee683fee9ee7d302d860ec3ee0ea104 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 54b1e75eded19ac065a4bf923a3370cd999c9f53..01bd3ee5ebc685f1c1735dfe375633d49c2c5437 100644 (file)
@@ -795,6 +795,7 @@ get_counters(const struct xt_table_info *t,
 
                        ADD_COUNTER(counters[i], bcnt, pcnt);
                        ++i;
+                       cond_resched();
                }
        }
 }