From: Greg Kroah-Hartman Date: Mon, 2 Sep 2019 17:27:12 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.4.191~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5d5ff0f604ee432074dddfcf9db173442dd0d8f;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: net-smc-make-sure-epollout-is-raised.patch tcp-make-sure-epollout-wont-be-missed.patch --- diff --git a/queue-4.14/net-smc-make-sure-epollout-is-raised.patch b/queue-4.14/net-smc-make-sure-epollout-is-raised.patch new file mode 100644 index 00000000000..de46cfb666f --- /dev/null +++ b/queue-4.14/net-smc-make-sure-epollout-is-raised.patch @@ -0,0 +1,53 @@ +From foo@baz Mon 02 Sep 2019 06:31:51 PM CEST +From: Jason Baron +Date: Mon, 19 Aug 2019 14:36:01 -0400 +Subject: net/smc: make sure EPOLLOUT is raised + +From: Jason Baron + +[ Upstream commit 4651d1802f7063e4d8c0bcad957f46ece0c04024 ] + +Currently, we are only explicitly setting SOCK_NOSPACE on a write timeout +for non-blocking sockets. Epoll() edge-trigger mode relies on SOCK_NOSPACE +being set when -EAGAIN is returned to ensure that EPOLLOUT is raised. +Expand the setting of SOCK_NOSPACE to non-blocking sockets as well that can +use SO_SNDTIMEO to adjust their write timeout. This mirrors the behavior +that Eric Dumazet introduced for tcp sockets. + +Signed-off-by: Jason Baron +Cc: Eric Dumazet +Cc: Ursula Braun +Cc: Karsten Graul +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/smc/smc_tx.c | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) + +--- a/net/smc/smc_tx.c ++++ b/net/smc/smc_tx.c +@@ -70,13 +70,11 @@ static int smc_tx_wait_memory(struct smc + DEFINE_WAIT_FUNC(wait, woken_wake_function); + struct smc_connection *conn = &smc->conn; + struct sock *sk = &smc->sk; +- bool noblock; + long timeo; + int rc = 0; + + /* similar to sk_stream_wait_memory */ + timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); +- noblock = timeo ? false : true; + add_wait_queue(sk_sleep(sk), &wait); + while (1) { + sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk); +@@ -91,8 +89,8 @@ static int smc_tx_wait_memory(struct smc + break; + } + if (!timeo) { +- if (noblock) +- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); ++ /* ensure EPOLLOUT is subsequently generated */ ++ set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); + rc = -EAGAIN; + break; + } diff --git a/queue-4.14/series b/queue-4.14/series index ea6ccedecf9..19e55ab454b 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -16,3 +16,5 @@ drm-tilcdc-register-cpufreq-notifier-after-we-have-i.patch tcp-fix-tcp_rtx_queue_tail-in-case-of-empty-retransm.patch alsa-usb-audio-fix-a-stack-buffer-overflow-bug-in-check_input_term.patch alsa-usb-audio-fix-an-oob-bug-in-parse_audio_mixer_unit.patch +net-smc-make-sure-epollout-is-raised.patch +tcp-make-sure-epollout-wont-be-missed.patch diff --git a/queue-4.14/tcp-make-sure-epollout-wont-be-missed.patch b/queue-4.14/tcp-make-sure-epollout-wont-be-missed.patch new file mode 100644 index 00000000000..24d57c87eb8 --- /dev/null +++ b/queue-4.14/tcp-make-sure-epollout-wont-be-missed.patch @@ -0,0 +1,82 @@ +From foo@baz Mon 02 Sep 2019 06:31:51 PM CEST +From: Eric Dumazet +Date: Fri, 16 Aug 2019 21:26:22 -0700 +Subject: tcp: make sure EPOLLOUT wont be missed + +From: Eric Dumazet + +[ Upstream commit ef8d8ccdc216f797e66cb4a1372f5c4c285ce1e4 ] + +As Jason Baron explained in commit 790ba4566c1a ("tcp: set SOCK_NOSPACE +under memory pressure"), it is crucial we properly set SOCK_NOSPACE +when needed. + +However, Jason patch had a bug, because the 'nonblocking' status +as far as sk_stream_wait_memory() is concerned is governed +by MSG_DONTWAIT flag passed at sendmsg() time : + + long timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); + +So it is very possible that tcp sendmsg() calls sk_stream_wait_memory(), +and that sk_stream_wait_memory() returns -EAGAIN with SOCK_NOSPACE +cleared, if sk->sk_sndtimeo has been set to a small (but not zero) +value. + +This patch removes the 'noblock' variable since we must always +set SOCK_NOSPACE if -EAGAIN is returned. + +It also renames the do_nonblock label since we might reach this +code path even if we were in blocking mode. + +Fixes: 790ba4566c1a ("tcp: set SOCK_NOSPACE under memory pressure") +Signed-off-by: Eric Dumazet +Cc: Jason Baron +Reported-by: Vladimir Rutsky +Acked-by: Soheil Hassas Yeganeh +Acked-by: Neal Cardwell +Acked-by: Jason Baron +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/core/stream.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +--- a/net/core/stream.c ++++ b/net/core/stream.c +@@ -120,7 +120,6 @@ int sk_stream_wait_memory(struct sock *s + int err = 0; + long vm_wait = 0; + long current_timeo = *timeo_p; +- bool noblock = (*timeo_p ? false : true); + DEFINE_WAIT_FUNC(wait, woken_wake_function); + + if (sk_stream_memory_free(sk)) +@@ -133,11 +132,8 @@ int sk_stream_wait_memory(struct sock *s + + if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) + goto do_error; +- if (!*timeo_p) { +- if (noblock) +- set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); +- goto do_nonblock; +- } ++ if (!*timeo_p) ++ goto do_eagain; + if (signal_pending(current)) + goto do_interrupted; + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk); +@@ -169,7 +165,13 @@ out: + do_error: + err = -EPIPE; + goto out; +-do_nonblock: ++do_eagain: ++ /* Make sure that whenever EAGAIN is returned, EPOLLOUT event can ++ * be generated later. ++ * When TCP receives ACK packets that make room, tcp_check_space() ++ * only calls tcp_new_space() if SOCK_NOSPACE is set. ++ */ ++ set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); + err = -EAGAIN; + goto out; + do_interrupted: