linux/include/net
Dan Streetman edaafa805e net: tcp: close sock if net namespace is exiting
[ Upstream commit 4ee806d511 ]

When a tcp socket is closed, if it detects that its net namespace is
exiting, close immediately and do not wait for FIN sequence.

For normal sockets, a reference is taken to their net namespace, so it will
never exit while the socket is open.  However, kernel sockets do not take a
reference to their net namespace, so it may begin exiting while the kernel
socket is still open.  In this case if the kernel socket is a tcp socket,
it will stay open trying to complete its close sequence.  The sock's dst(s)
hold a reference to their interface, which are all transferred to the
namespace's loopback interface when the real interfaces are taken down.
When the namespace tries to take down its loopback interface, it hangs
waiting for all references to the loopback interface to release, which
results in messages like:

unregister_netdevice: waiting for lo to become free. Usage count = 1

These messages continue until the socket finally times out and closes.
Since the net namespace cleanup holds the net_mutex while calling its
registered pernet callbacks, any new net namespace initialization is
blocked until the current net namespace finishes exiting.

After this change, the tcp socket notices the exiting net namespace, and
closes immediately, releasing its dst(s) and their reference to the
loopback interface, which lets the net namespace continue exiting.

Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1711407
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=97811
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-31 12:06:14 +01:00
..
9p
bluetooth
caif
irda
iucv
netfilter
netns
nfc
phonet
sctp sctp: potential read out of bounds in sctp_ulpevent_type_enabled() 2017-10-21 17:09:01 +02:00
tc_act
6lowpan.h
act_api.h
addrconf.h ipv6: reorder ip6_route_dev_notifier after ipv6_dev_notf 2017-05-14 13:32:58 +02:00
af_ieee802154.h
af_rxrpc.h
af_unix.h af_unix: split 'u->readlock' into two: 'iolock' and 'bindlock' 2016-09-30 10:18:36 +02:00
af_vsock.h
ah.h
arp.h ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY 2018-01-31 12:06:14 +01:00
atmclip.h
ax25.h
ax88796.h
bond_3ad.h
bond_alb.h
bond_options.h
bonding.h
busy_poll.h
cfg80211-wext.h
cfg80211.h cfg80211/mac80211: fix BSS leaks when abandoning assoc attempts 2017-01-09 08:07:42 +01:00
cfg802154.h
checksum.h
cipso_ipv4.h netlabel: out of bound access in cipso_v4_validate() 2017-02-18 16:39:26 +01:00
cls_cgroup.h
codel.h net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
compat.h
datalink.h
dcbevent.h
dcbnl.h
dn_dev.h
dn_fib.h
dn_neigh.h
dn_nsp.h
dn_route.h
dn.h
dsa.h
dsfield.h
dst_metadata.h
dst_ops.h
dst.h ipv4: add reference counting to metrics 2017-06-07 12:05:59 +02:00
esp.h
ethoc.h
fib_rules.h
firewire.h
flow_dissector.h
flow.h
flowcache.h
fou.h
garp.h
gen_stats.h
genetlink.h netlink: add a start callback for starting a netlink dump 2017-12-05 11:22:49 +01:00
geneve.h
gre.h
gro_cells.h
gue.h
icmp.h
ieee80211_radiotap.h
ieee802154_netdev.h
if_inet6.h
inet_common.h
inet_connection_sock.h
inet_ecn.h
inet_frag.h Revert "net: fix percpu memory leaks" 2017-09-27 11:00:11 +02:00
inet_hashtables.h
inet_sock.h tcp/dccp: fix other lockdep splats accessing ireq_opt 2017-11-18 11:11:07 +01:00
inet_timewait_sock.h
inet6_connection_sock.h
inet6_hashtables.h
inetpeer.h
ip_fib.h ipv4: add reference counting to metrics 2017-06-07 12:05:59 +02:00
ip_tunnels.h tunnels: Remove encapsulation offloads on decap. 2016-10-31 04:13:59 -06:00
ip_vs.h
ip.h ipv4: igmp: guard against silly MTU values 2018-01-02 20:33:24 +01:00
ip6_checksum.h
ip6_fib.h ipv6: fix sparse warning on rt6i_node 2017-09-27 11:00:10 +02:00
ip6_route.h net: ipv6: Compare lwstate in detecting duplicate nexthops 2017-07-21 07:44:55 +02:00
ip6_tunnel.h ip6_tunnel: Clear IP6CB in ip6tunnel_xmit() 2016-11-21 10:06:39 +01:00
ipcomp.h
ipconfig.h
ipv6.h ipv6: Fix getsockopt() for sockets with default IPV6_AUTOFLOWLABEL 2018-01-31 12:06:12 +01:00
ipx.h
iw_handler.h wext: handle NULL extra data in iwe_stream_add_point better 2017-08-11 09:08:56 -07:00
l3mdev.h
lapb.h
lib80211.h
llc_c_ac.h
llc_c_ev.h
llc_c_st.h
llc_conn.h
llc_if.h
llc_pdu.h
llc_s_ac.h
llc_s_ev.h
llc_s_st.h
llc_sap.h
llc.h
lwtunnel.h
mac80211.h mac80211: RX BA support for sta max_rx_aggregation_subframes 2017-05-20 14:27:03 +02:00
mac802154.h
mip6.h
mld.h
mpls_iptunnel.h
mpls.h
mrp.h
ndisc.h
neighbour.h
net_namespace.h net: tcp: close sock if net namespace is exiting 2018-01-31 12:06:14 +01:00
net_ratelimit.h
netevent.h
netlabel.h
netlink.h
netprio_cgroup.h
netrom.h
nexthop.h
nl802154.h
p8022.h
ping.h
pkt_cls.h
pkt_sched.h
protocol.h
psnap.h
raw.h
rawv6.h
red.h
regulatory.h
request_sock.h
rose.h
route.h
rtnetlink.h
sch_generic.h net_sched: fix order of queue length updates in qdisc_replace() 2017-08-30 10:19:21 +02:00
scm.h
secure_seq.h
slhc_vj.h
snmp.h
sock.h net: avoid sk_forward_alloc overflows 2016-11-15 07:46:36 +01:00
Space.h
stp.h
switchdev.h switchdev: pass pointer to fib_info instead of copy 2016-06-24 10:18:16 -07:00
tcp_memcontrol.h
tcp_states.h
tcp.h tcp: fix tcp_mtu_probe() vs highest_sack 2017-11-18 11:11:05 +01:00
timewait_sock.h
transp_v6.h
tso.h
udp_tunnel.h
udp.h
udplite.h
vsock_addr.h
vxlan.h
wext.h
wimax.h
x25.h
x25device.h
xfrm.h xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY 2017-07-05 14:37:21 +02:00