Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update From Base #11

Merged
merged 84 commits into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
838cda3
x86/PCI: Enable AMD 64-bit window on resume
Jan 16, 2018
cc01572
xfrm: Add SA to hardware at the end of xfrm_state_construct()
Jan 17, 2018
f61145f
drm/vc4: Flush the caches before the bin jobs, as well.
anholt Dec 21, 2017
17b11b7
drm/vc4: Fix NULL pointer dereference in vc4_save_hang_state()
Jan 18, 2018
aa5dd6f
xfrm: fix error flow in case of add state fails
aviadye Jan 18, 2018
f30fefd
Input: stmfts,s6sy671 - add SPDX identifier
Jan 22, 2018
e5c9c6a
Input: xpad - add support for PDP Xbox One controllers
TheUbuntuGuy Jan 22, 2018
f5d07b9
Input: trackpoint - force 3 buttons if 0 button is reported
pyma1 Jan 19, 2018
2a924d7
Input: trackpoint - only expose supported controls for Elan, ALPS and…
dtor Jan 5, 2018
5efec5c
xfrm: Fix eth_hdr(skb)->h_proto to reflect inner IP version
Jan 22, 2018
545d8ae
xfrm: fix boolean assignment in xfrm_get_type_offload
GustavoARSilva Jan 22, 2018
e2ac83d
x86/ftrace: Fix ORC unwinding from ftrace handlers
jpoimboe Jan 23, 2018
1f07476
Merge tag 'pci-v4.15-fixes-3' of git://git.kernel.org/pub/scm/linux/k…
torvalds Jan 23, 2018
6be7fa3
ftrace, orc, x86: Handle ftrace dynamically allocated trampolines
rostedt Jan 23, 2018
2ee5b92
tracing: Update stack trace skipping for ORC unwinder
rostedt Jan 23, 2018
02612bb
pppoe: take ->needed_headroom of lower device into account on xmit
Jan 22, 2018
e9191ff
ipv6: Fix getsockopt() for sockets with default IPV6_AUTOFLOWLABEL
bwh-ct Jan 22, 2018
848b159
vmxnet3: repair memory leak
nhorman Jan 22, 2018
a97cb0e
futex: Fix OWNER_DEAD fixup
Jan 22, 2018
88f1c87
locking/lockdep: Avoid triggering hardlockup from debug_show_all_locks()
htejun Jan 22, 2018
ce48c14
sched/core: Fix cpu.max vs. cpuhotplug deadlock
Jan 22, 2018
1df3738
x86/retpoline: Remove the esp/rsp thunk
Waiman-Long Jan 22, 2018
40d4071
perf/x86/amd/power: Do not load AMD power module on !AMD platforms
liangxiao1 Jan 22, 2018
7e702d1
x86/microcode/intel: Extend BDW late-loading further with LLC size check
jiazhang0 Jan 23, 2018
1d080f0
x86/microcode: Fix again accessing initrd after having been freed
suryasaimadhu Jan 23, 2018
1de1ea7
KVM: s390: add proper locking for CMMA migration bitmap
borntraeger Dec 22, 2017
bda646d
Merge tag 'kvm-s390-master-4.15-3' of git://git.kernel.org/pub/scm/li…
rkrcmar Jan 24, 2018
97edf7c
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
davem330 Jan 24, 2018
1ecdaea
mlxsw: spectrum_router: Don't log an error on missing neighbor
Jan 24, 2018
5132ede
Revert "module: Add retpoline tag to VERMAGIC"
gregkh Jan 24, 2018
ce30f26
MAINTAINERS: clarify that only verified bugs should be submitted to s…
wtarreau Jan 4, 2018
03fae44
Merge tag 'trace-v4.15-rc9' of git://git.kernel.org/pub/scm/linux/ker…
torvalds Jan 24, 2018
e4fd493
Btrfs: fix stale entries in readdir
Jan 23, 2018
560a660
net: sched: em_nbyte: don't add the data offset twice
Blub Jan 18, 2018
d3303a6
net: sched: fix TCF_LAYER_LINK case in tcf_get_base_ptr
Blub Jan 18, 2018
3eab2ad
MAINTAINERS: update email address for James Morris
Jan 24, 2018
581e722
kcm: Only allow TCP sockets to be attached to a KCM mux
Jan 24, 2018
e557124
kcm: Check if sk_user_data already set in kcm_attach
Jan 24, 2018
88d1d76
Merge branch 'kcm-fix-two-syzcaller-issues'
davem330 Jan 24, 2018
4de4947
qed: Remove reserveration of dpi for kernel
mkalderon Jan 23, 2018
1fe280a
qed: Free reserved MR tid
mkalderon Jan 23, 2018
ee45bea
Merge branch 'qed-rdma-bug-fixes'
davem330 Jan 24, 2018
aebb48f
sparc64: fix typo in CONFIG_CRYPTO_DES_SPARC64 => CONFIG_CRYPTO_CAMEL…
montjoie Jan 23, 2018
b7051cb
i40e: flower: check if TC offload is enabled on a netdev
Jan 23, 2018
e9cb423
vhost: use mutex_lock_nested() in vhost_dev_lock_vqs()
jasowang Jan 23, 2018
6f3180a
vhost: do not try to access device IOTLB when not initialized
jasowang Jan 23, 2018
060403f
Revert "Input: synaptics_rmi4 - use devm_device_add_group() for attri…
ndyer Jan 24, 2018
45d6e54
net/ibm/emac: add 8192 rx/tx fifo size
Jan 24, 2018
624ca9c
net/ibm/emac: wrong bit is used for STA control register write
Jan 24, 2018
f165495
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
torvalds Jan 24, 2018
5b7d279
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
torvalds Jan 25, 2018
7e3f8e9
Merge tag 'drm-misc-fixes-2018-01-24' of git://anongit.freedesktop.or…
airlied Jan 25, 2018
82d9485
perf/core: Fix lock inversion between perf,trace,cpuhp
Jan 9, 2018
43fa87f
perf/core: Fix another perf,trace,cpuhp lock inversion
Jan 9, 2018
0c7296c
perf/core: Fix ctx::mutex deadlock
Jan 9, 2018
efe951d
perf/x86: Fix perf,x86,cpuhp deadlock
Jan 10, 2018
4ee806d
net: tcp: close sock if net namespace is exiting
ddstreet Jan 18, 2018
525273f
Merge tag 'for-4.15-tag' of git://git.kernel.org/pub/scm/linux/kernel…
torvalds Jan 25, 2018
6e20630
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
torvalds Jan 25, 2018
f15ca72
net: don't call update_pmtu unconditionally
NicolasDichtel Jan 25, 2018
0fd189a
drm/nouveau: Move irq setup/teardown to pci ctor/dtor
Lyude Jan 25, 2018
6793f1c
orangefs: fix deadlock; do not write i_size in read_iter
Jan 26, 2018
993ca20
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
torvalds Jan 26, 2018
a78e936
r8169: fix memory corruption on retrieval of hardware statistics.
Jan 26, 2018
1e19c4d
net: vrf: Add support for sends to local broadcast address
dsahern Jan 25, 2018
baa35cc
Merge branch 'linux-4.15' of git://github.com/skeggsb/linux into drm-…
airlied Jan 26, 2018
5beda7d
x86/mm/64: Fix vmapped stack syncing on very-large-memory 4-level sys…
amluto Jan 25, 2018
36b3a77
x86/mm/64: Tighten up vmalloc_fault() sanity checks on 5-level kernels
amluto Jan 25, 2018
6572cc2
Update the RISC-V MAINTAINERS file
palmer-dabbelt Jan 24, 2018
dd5684e
dccp: don't restart ccid2_hc_tx_rto_expire() if sk in closed state
akodanev Jan 26, 2018
ba3169f
VSOCK: set POLLOUT | POLLWRNORM for TCP_CLOSING
stefanhaRH Jan 26, 2018
db21854
Merge tag 'drm-fixes-for-v4.15-rc10-2' of git://people.freedesktop.or…
torvalds Jan 26, 2018
ba804bb
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
torvalds Jan 26, 2018
c4e0ca7
Merge tag 'riscv-for-linus-4.15-maintainers' of git://git.kernel.org/…
torvalds Jan 26, 2018
8a95b74
x86: Mark hpa as a "Designated Reviewer" for the time being
Jan 25, 2018
d5421ea
hrtimer: Reset hrtimer cpu base proper on CPU hotplug
KAGA-KOKO Jan 26, 2018
dd08516
x86/ftrace: Add one more ENDPROC annotation
jpoimboe Jan 28, 2018
8c76e31
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/s…
torvalds Jan 28, 2018
39e3836
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
torvalds Jan 28, 2018
6244419
Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm…
torvalds Jan 28, 2018
07b0137
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/sc…
torvalds Jan 28, 2018
32c6cdf
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/l…
torvalds Jan 28, 2018
24b1ccc
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linu…
torvalds Jan 28, 2018
d8a5b80
Linux 4.15
torvalds Jan 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
net: tcp: close sock if net namespace is exiting
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>
  • Loading branch information
ddstreet authored and davem330 committed Jan 25, 2018
commit 4ee806d51176ba7b8ff1efd81f271d7252e03a1d
10 changes: 10 additions & 0 deletions include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ int net_eq(const struct net *net1, const struct net *net2)
return net1 == net2;
}

static inline int check_net(const struct net *net)
{
return atomic_read(&net->count) != 0;
}

void net_drop_ns(void *);

#else
Expand All @@ -247,6 +252,11 @@ int net_eq(const struct net *net1, const struct net *net2)
return 1;
}

static inline int check_net(const struct net *net)
{
return 1;
}

#define net_drop_ns NULL
#endif

Expand Down
3 changes: 3 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,9 @@ void tcp_close(struct sock *sk, long timeout)
tcp_send_active_reset(sk, GFP_ATOMIC);
__NET_INC_STATS(sock_net(sk),
LINUX_MIB_TCPABORTONMEMORY);
} else if (!check_net(sock_net(sk))) {
/* Not possible to send reset; just close */
tcp_set_state(sk, TCP_CLOSE);
}
}

Expand Down
15 changes: 15 additions & 0 deletions net/ipv4/tcp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ static void tcp_write_err(struct sock *sk)
* to prevent DoS attacks. It is called when a retransmission timeout
* or zero probe timeout occurs on orphaned socket.
*
* Also close if our net namespace is exiting; in that case there is no
* hope of ever communicating again since all netns interfaces are already
* down (or about to be down), and we need to release our dst references,
* which have been moved to the netns loopback interface, so the namespace
* can finish exiting. This condition is only possible if we are a kernel
* socket, as those do not hold references to the namespace.
*
* Criteria is still not confirmed experimentally and may change.
* We kill the socket, if:
* 1. If number of orphaned sockets exceeds an administratively configured
* limit.
* 2. If we have strong memory pressure.
* 3. If our net namespace is exiting.
*/
static int tcp_out_of_resources(struct sock *sk, bool do_reset)
{
Expand Down Expand Up @@ -81,6 +89,13 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
return 1;
}

if (!check_net(sock_net(sk))) {
/* Not possible to send reset; just close */
tcp_done(sk);
return 1;
}

return 0;
}

Expand Down