Files
linuxkit/kernel/patches-4.11.x/0011-hvsock-fix-vsock_dequeue-enqueue_accept-race.patch
Rolf Neugebauer aa9b718d8a kernel: Update to 4.11.9/4.9.36/4.4.76
Added a new patch to the 4.11 and 4.9 kernels based on a patch
submitted to stable: https://patchwork.kernel.org/patch/9829039/

This patch fixes a off-by-one error in the VMBus code.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-07-07 18:41:33 +01:00

49 lines
1.6 KiB
Diff

From 2517cc6863d81f64da73fcc715458f5331a3eed0 Mon Sep 17 00:00:00 2001
From: Dexuan Cui <decui@microsoft.com>
Date: Fri, 19 May 2017 21:49:59 +0800
Subject: [PATCH 11/15] hvsock: fix vsock_dequeue/enqueue_accept race
Origin: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511-debug-0605
(cherry picked from commit 29e6c6204845176c78c7840377a72389d188563c)
---
net/vmw_vsock/af_vsock.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 6f7f6757ceef..717db396f59e 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -126,6 +126,7 @@ static struct proto vsock_proto = {
static const struct vsock_transport *transport;
static DEFINE_MUTEX(vsock_register_mutex);
+static DEFINE_SPINLOCK(vsock_accept_queue_lock);
/**** EXPORTS ****/
@@ -406,7 +407,10 @@ void vsock_enqueue_accept(struct sock *listener, struct sock *connected)
sock_hold(connected);
sock_hold(listener);
+
+ spin_lock(&vsock_accept_queue_lock);
list_add_tail(&vconnected->accept_queue, &vlistener->accept_queue);
+ spin_unlock(&vsock_accept_queue_lock);
}
EXPORT_SYMBOL_GPL(vsock_enqueue_accept);
@@ -423,7 +427,10 @@ static struct sock *vsock_dequeue_accept(struct sock *listener)
vconnected = list_entry(vlistener->accept_queue.next,
struct vsock_sock, accept_queue);
+ spin_lock(&vsock_accept_queue_lock);
list_del_init(&vconnected->accept_queue);
+ spin_unlock(&vsock_accept_queue_lock);
+
sock_put(listener);
/* The caller will need a reference on the connected socket so we let
* it call sock_put().
--
2.13.0