acrn-kernel/net/netfilter/ipvs
Julian Anastasov d5e032fc56 ipvs: fix stats update from local clients
Local clients are not properly synchronized on 32-bit CPUs when
updating stats (3.10+). Now it is possible estimation_timer (timer),
a stats reader, to interrupt the local client in the middle of
write_seqcount_{begin,end} sequence leading to loop (DEADLOCK).
The same interrupt can happen from received packet (SoftIRQ)
which updates the same per-CPU stats.

Fix it by disabling BH while updating stats.

Found with debug:

WARNING: inconsistent lock state
4.17.0-rc2-00105-g35cb6d7-dirty #2 Not tainted
--------------------------------
inconsistent {IN-SOFTIRQ-R} -> {SOFTIRQ-ON-W} usage.
ftp/2545 [HC0[0]:SC0[0]:HE1:SE1] takes:
86845479 (&syncp->seq#6){+.+-}, at: ip_vs_schedule+0x1c5/0x59e [ip_vs]
{IN-SOFTIRQ-R} state was registered at:
 lock_acquire+0x44/0x5b
 estimation_timer+0x1b3/0x341 [ip_vs]
 call_timer_fn+0x54/0xcd
 run_timer_softirq+0x10c/0x12b
 __do_softirq+0xc1/0x1a9
 do_softirq_own_stack+0x1d/0x23
 irq_exit+0x4a/0x64
 smp_apic_timer_interrupt+0x63/0x71
 apic_timer_interrupt+0x3a/0x40
 default_idle+0xa/0xc
 arch_cpu_idle+0x9/0xb
 default_idle_call+0x21/0x23
 do_idle+0xa0/0x167
 cpu_startup_entry+0x19/0x1b
 start_secondary+0x133/0x182
 startup_32_smp+0x164/0x168
irq event stamp: 42213

other info that might help us debug this:
Possible unsafe locking scenario:

      CPU0
      ----
 lock(&syncp->seq#6);
 <Interrupt>
   lock(&syncp->seq#6);

*** DEADLOCK ***

Fixes: ac69269a45 ("ipvs: do not disable bh for long time")
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2018-05-08 14:15:21 +02:00
..
Kconfig
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ip_vs_app.c netfilter: delete /proc THIS_MODULE references 2018-01-19 14:10:53 +01:00
ip_vs_conn.c ipvs: fix refcount usage for conns in ops mode 2018-05-08 14:15:12 +02:00
ip_vs_core.c ipvs: fix stats update from local clients 2018-05-08 14:15:21 +02:00
ip_vs_ctl.c ipvs: fix rtnl_lock lockups caused by start_sync_thread 2018-04-09 17:05:27 +02:00
ip_vs_dh.c
ip_vs_est.c netfilter: ipvs: Convert timers to use timer_setup() 2017-11-08 15:53:58 -08:00
ip_vs_fo.c
ip_vs_ftp.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
ip_vs_lblc.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next 2018-03-30 11:41:18 -04:00
ip_vs_lblcr.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next 2018-03-30 11:41:18 -04:00
ip_vs_lc.c
ip_vs_nfct.c
ip_vs_nq.c
ip_vs_ovf.c
ip_vs_pe.c
ip_vs_pe_sip.c
ip_vs_proto.c
ip_vs_proto_ah_esp.c
ip_vs_proto_sctp.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ip_vs_proto_tcp.c netfilter: mark expected switch fall-throughs 2018-01-08 18:01:01 +01:00
ip_vs_proto_udp.c netfilter: mark expected switch fall-throughs 2018-01-08 18:01:01 +01:00
ip_vs_rr.c
ip_vs_sched.c
ip_vs_sed.c
ip_vs_sh.c
ip_vs_sync.c ipvs: fix rtnl_lock lockups caused by start_sync_thread 2018-04-09 17:05:27 +02:00
ip_vs_wlc.c
ip_vs_wrr.c
ip_vs_xmit.c netfilter: ipvs: full-functionality option for ECN encapsulation in tunnel 2017-09-26 14:06:33 +02:00