From: Greg Kroah-Hartman Date: Mon, 15 Feb 2021 14:57:02 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v5.4.99~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0cb0ab81745322d1e7bc53897c3234c09e1844ef;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: net-watchdog-hold-device-global-xmit-lock-during-tx-disable.patch vsock-fix-locking-in-vsock_shutdown.patch --- diff --git a/queue-4.4/net-watchdog-hold-device-global-xmit-lock-during-tx-disable.patch b/queue-4.4/net-watchdog-hold-device-global-xmit-lock-during-tx-disable.patch new file mode 100644 index 00000000000..9b1e52cfaf4 --- /dev/null +++ b/queue-4.4/net-watchdog-hold-device-global-xmit-lock-during-tx-disable.patch @@ -0,0 +1,47 @@ +From 3aa6bce9af0e25b735c9c1263739a5639a336ae8 Mon Sep 17 00:00:00 2001 +From: Edwin Peer +Date: Fri, 5 Feb 2021 17:37:32 -0800 +Subject: net: watchdog: hold device global xmit lock during tx disable + +From: Edwin Peer + +commit 3aa6bce9af0e25b735c9c1263739a5639a336ae8 upstream. + +Prevent netif_tx_disable() running concurrently with dev_watchdog() by +taking the device global xmit lock. Otherwise, the recommended: + + netif_carrier_off(dev); + netif_tx_disable(dev); + +driver shutdown sequence can happen after the watchdog has already +checked carrier, resulting in possible false alarms. This is because +netif_tx_lock() only sets the frozen bit without maintaining the locks +on the individual queues. + +Fixes: c3f26a269c24 ("netdev: Fix lockdep warnings in multiqueue configurations.") +Signed-off-by: Edwin Peer +Reviewed-by: Jakub Kicinski +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/netdevice.h | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -3428,6 +3428,7 @@ static inline void netif_tx_disable(stru + + local_bh_disable(); + cpu = smp_processor_id(); ++ spin_lock(&dev->tx_global_lock); + for (i = 0; i < dev->num_tx_queues; i++) { + struct netdev_queue *txq = netdev_get_tx_queue(dev, i); + +@@ -3435,6 +3436,7 @@ static inline void netif_tx_disable(stru + netif_tx_stop_queue(txq); + __netif_tx_unlock(txq); + } ++ spin_unlock(&dev->tx_global_lock); + local_bh_enable(); + } + diff --git a/queue-4.4/series b/queue-4.4/series index d931909fff8..d109bdbfea8 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -16,3 +16,5 @@ netfilter-xt_recent-fix-attempt-to-update-deleted-en.patch h8300-fix-preemption-build-ti_pre_count-undefined.patch usb-dwc3-ulpi-fix-checkpatch-warning.patch usb-dwc3-ulpi-replace-cpu-based-busyloop-with-protocol-based-one.patch +net-watchdog-hold-device-global-xmit-lock-during-tx-disable.patch +vsock-fix-locking-in-vsock_shutdown.patch diff --git a/queue-4.4/vsock-fix-locking-in-vsock_shutdown.patch b/queue-4.4/vsock-fix-locking-in-vsock_shutdown.patch new file mode 100644 index 00000000000..c8be35cd79d --- /dev/null +++ b/queue-4.4/vsock-fix-locking-in-vsock_shutdown.patch @@ -0,0 +1,68 @@ +From 1c5fae9c9a092574398a17facc31c533791ef232 Mon Sep 17 00:00:00 2001 +From: Stefano Garzarella +Date: Tue, 9 Feb 2021 09:52:19 +0100 +Subject: vsock: fix locking in vsock_shutdown() + +From: Stefano Garzarella + +commit 1c5fae9c9a092574398a17facc31c533791ef232 upstream. + +In vsock_shutdown() we touched some socket fields without holding the +socket lock, such as 'state' and 'sk_flags'. + +Also, after the introduction of multi-transport, we are accessing +'vsk->transport' in vsock_send_shutdown() without holding the lock +and this call can be made while the connection is in progress, so +the transport can change in the meantime. + +To avoid issues, we hold the socket lock when we enter in +vsock_shutdown() and release it when we leave. + +Among the transports that implement the 'shutdown' callback, only +hyperv_transport acquired the lock. Since the caller now holds it, +we no longer take it. + +Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") +Signed-off-by: Stefano Garzarella +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + net/vmw_vsock/af_vsock.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +--- a/net/vmw_vsock/af_vsock.c ++++ b/net/vmw_vsock/af_vsock.c +@@ -818,10 +818,12 @@ static int vsock_shutdown(struct socket + */ + + sk = sock->sk; ++ ++ lock_sock(sk); + if (sock->state == SS_UNCONNECTED) { + err = -ENOTCONN; + if (sk->sk_type == SOCK_STREAM) +- return err; ++ goto out; + } else { + sock->state = SS_DISCONNECTING; + err = 0; +@@ -830,10 +832,8 @@ static int vsock_shutdown(struct socket + /* Receive and send shutdowns are treated alike. */ + mode = mode & (RCV_SHUTDOWN | SEND_SHUTDOWN); + if (mode) { +- lock_sock(sk); + sk->sk_shutdown |= mode; + sk->sk_state_change(sk); +- release_sock(sk); + + if (sk->sk_type == SOCK_STREAM) { + sock_reset_flag(sk, SOCK_DONE); +@@ -841,6 +841,8 @@ static int vsock_shutdown(struct socket + } + } + ++out: ++ release_sock(sk); + return err; + } +