1
0
Fork 0
remarkable-linux/net/netfilter/ipvs
Tan Hu ccf1ae823e ipvs: fix race between ip_vs_conn_new() and ip_vs_del_dest()
[ Upstream commit a53b42c118 ]

We came across infinite loop in ipvs when using ipvs in docker
env.

When ipvs receives new packets and cannot find an ipvs connection,
it will create a new connection, then if the dest is unavailable
(i.e. IP_VS_DEST_F_AVAILABLE), the packet will be dropped sliently.

But if the dropped packet is the first packet of this connection,
the connection control timer never has a chance to start and the
ipvs connection cannot be released. This will lead to memory leak, or
infinite loop in cleanup_net() when net namespace is released like
this:

    ip_vs_conn_net_cleanup at ffffffffa0a9f31a [ip_vs]
    __ip_vs_cleanup at ffffffffa0a9f60a [ip_vs]
    ops_exit_list at ffffffff81567a49
    cleanup_net at ffffffff81568b40
    process_one_work at ffffffff810a851b
    worker_thread at ffffffff810a9356
    kthread at ffffffff810b0b6f
    ret_from_fork at ffffffff81697a18

race condition:
    CPU1                           CPU2
    ip_vs_in()
      ip_vs_conn_new()
                                   ip_vs_del_dest()
                                     __ip_vs_unlink_dest()
                                       ~IP_VS_DEST_F_AVAILABLE
      cp->dest && !IP_VS_DEST_F_AVAILABLE
      __ip_vs_conn_put
    ...
    cleanup_net  ---> infinite looping

Fix this by checking whether the timer already started.

Signed-off-by: Tan Hu <tan.hu@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
Acked-by: Julian Anastasov <ja@ssi.bg>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-15 09:45:28 +02:00
..
Kconfig ipvs: Add ovf scheduler 2015-08-21 09:08:39 -07:00
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: ipvs: avoid unused variable warnings 2016-02-18 09:17:58 +09:00
ip_vs_conn.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_core.c ipvs: fix race between ip_vs_conn_new() and ip_vs_del_dest() 2018-09-15 09:45:28 +02:00
ip_vs_ctl.c ipvs: fix buffer overflow with sync daemon and service 2018-07-08 15:30:52 +02:00
ip_vs_dh.c lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
ip_vs_est.c ipvs: Pass ipvs not net to ip_vs_estimator_net_init and ip_vs_estimator_cleanup 2015-09-24 09:34:39 +09:00
ip_vs_fo.c ipvs: use correct address family in scheduler logs 2014-09-18 08:59:23 +09:00
ip_vs_ftp.c ipvs: remove IPS_NAT_MASK check to fix passive FTP 2018-05-30 07:52:07 +02:00
ip_vs_lblc.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_lblcr.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_lc.c ipvs: use correct address family in scheduler logs 2014-09-18 08:59:23 +09:00
ip_vs_nfct.c netfilter: remove nf_ct_is_untracked 2017-04-15 11:51:33 +02:00
ip_vs_nq.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_ovf.c ipvs: Add ovf scheduler 2015-08-21 09:08:39 -07:00
ip_vs_pe.c netfilter: Deletion of unnecessary checks before two function calls 2014-11-20 13:08:43 +01:00
ip_vs_pe_sip.c ipvs: handle connections started by real-servers 2016-04-20 12:34:17 +10:00
ip_vs_proto.c ipvs: remove unused function ip_vs_set_state_timeout 2017-04-28 12:00:10 +02:00
ip_vs_proto_ah_esp.c ipvs: Pass ipvs into .conn_schedule and ip_vs_try_to_schedule 2015-09-24 09:34:41 +09:00
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: Remove duplicated rcu_read_lock. 2017-07-24 13:24:46 +02:00
ip_vs_proto_udp.c netfilter: Remove duplicated rcu_read_lock. 2017-07-24 13:24:46 +02:00
ip_vs_rr.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_sched.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-next 2015-08-04 23:57:45 -07:00
ip_vs_sed.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_sh.c lib/vsprintf.c: remove %Z support 2017-02-27 18:43:47 -08:00
ip_vs_sync.c ipvs: fix rtnl_lock lockups caused by start_sync_thread 2018-05-16 10:10:22 +02:00
ip_vs_wlc.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_wrr.c netfilter: refcounter conversions 2017-03-17 12:49:43 +01:00
ip_vs_xmit.c netfilter: ipvs: full-functionality option for ECN encapsulation in tunnel 2017-09-26 14:06:33 +02:00