From: Greg Kroah-Hartman Date: Tue, 3 Mar 2020 15:53:52 +0000 (+0100) Subject: 4.14-stable patches X-Git-Tag: v4.19.108~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aab36f278ccd5743688951060d19d3331aa503aa;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: tuntap-correctly-set-sockwq_async_nospace.patch --- diff --git a/queue-4.14/series b/queue-4.14/series index 180037ade5b..8417ba4bbb6 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -58,3 +58,4 @@ namei-only-return-echild-from-follow_dotdot_rcu.patch mwifiex-drop-most-magic-numbers-from-mwifiex_process_tdls_action_frame.patch kvm-svm-override-default-mmio-mask-if-memory-encryption-is-enabled.patch kvm-check-for-a-bad-hva-before-dropping-into-the-ghc-slow-path.patch +tuntap-correctly-set-sockwq_async_nospace.patch diff --git a/queue-4.14/tuntap-correctly-set-sockwq_async_nospace.patch b/queue-4.14/tuntap-correctly-set-sockwq_async_nospace.patch new file mode 100644 index 00000000000..376c65d977e --- /dev/null +++ b/queue-4.14/tuntap-correctly-set-sockwq_async_nospace.patch @@ -0,0 +1,68 @@ +From 2f3ab6221e4c87960347d65c7cab9bd917d1f637 Mon Sep 17 00:00:00 2001 +From: Jason Wang +Date: Tue, 22 May 2018 14:21:04 +0800 +Subject: tuntap: correctly set SOCKWQ_ASYNC_NOSPACE + +From: Jason Wang + +commit 2f3ab6221e4c87960347d65c7cab9bd917d1f637 upstream. + +When link is down, writes to the device might fail with +-EIO. Userspace needs an indication when the status is resolved. As a +fix, tun_net_open() attempts to wake up writers - but that is only +effective if SOCKWQ_ASYNC_NOSPACE has been set in the past. This is +not the case of vhost_net which only poll for EPOLLOUT after it meets +errors during sendmsg(). + +This patch fixes this by making sure SOCKWQ_ASYNC_NOSPACE is set when +socket is not writable or device is down to guarantee EPOLLOUT will be +raised in either tun_chr_poll() or tun_sock_write_space() after device +is up. + +Cc: Hannes Frederic Sowa +Cc: Eric Dumazet +Fixes: 1bd4978a88ac2 ("tun: honor IFF_UP in tun_get_user()") +Signed-off-by: Jason Wang +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Tommi Rantala + +--- + drivers/net/tun.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +--- a/drivers/net/tun.c ++++ b/drivers/net/tun.c +@@ -1134,6 +1134,13 @@ static void tun_net_init(struct net_devi + dev->max_mtu = MAX_MTU - dev->hard_header_len; + } + ++static bool tun_sock_writeable(struct tun_struct *tun, struct tun_file *tfile) ++{ ++ struct sock *sk = tfile->socket.sk; ++ ++ return (tun->dev->flags & IFF_UP) && sock_writeable(sk); ++} ++ + /* Character device part */ + + /* Poll */ +@@ -1156,10 +1163,14 @@ static unsigned int tun_chr_poll(struct + if (!skb_array_empty(&tfile->tx_array)) + mask |= POLLIN | POLLRDNORM; + +- if (tun->dev->flags & IFF_UP && +- (sock_writeable(sk) || +- (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && +- sock_writeable(sk)))) ++ /* Make sure SOCKWQ_ASYNC_NOSPACE is set if not writable to ++ * guarantee EPOLLOUT to be raised by either here or ++ * tun_sock_write_space(). Then process could get notification ++ * after it writes to a down device and meets -EIO. ++ */ ++ if (tun_sock_writeable(tun, tfile) || ++ (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) && ++ tun_sock_writeable(tun, tfile))) + mask |= POLLOUT | POLLWRNORM; + + if (tun->dev->reg_state != NETREG_REGISTERED)