From patchwork Tue Jun 20 17:27:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 778426 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3wsZYv5J4yz9s7m; Wed, 21 Jun 2017 03:28:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="O1qEz8YZ"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dNMwq-0001nA-VT; Tue, 20 Jun 2017 17:28:16 +0000 Received: from mail-ua0-f173.google.com ([209.85.217.173]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dNMwd-0001gZ-Ub for kernel-team@lists.ubuntu.com; Tue, 20 Jun 2017 17:28:04 +0000 Received: by mail-ua0-f173.google.com with SMTP id 70so23027748uau.0 for ; Tue, 20 Jun 2017 10:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aiDAuVFNTqDieRfxgbTiYbYD42OLD9sOlocc8uI46o0=; b=O1qEz8YZI/+RmpRzL6SbNCCWMXXgPO9Lse0iVlcZiWBKB+WGBlZPcwJ+nLIcPE88Pm n2RvhBrOH1hR/g9THTrykQvTas44g22/VCyLgbFnN01tom6g63tCnjA+4Wpl3Y+pO2lz guvWcJsumQ891OO8VJ0sLXjwBvkoXFHn2LiRKH0B/B12POp7GI8WMEl3VtKzPPSfY/ME aLCapD2fVlJIeDcQL92PnUDXLNlcY84bNJ/MeFLGSX7ePX8KyRdgDkAEnZ4MmjGEM44r sOCND4A+WjkaHTi0RrgedZyQKV/JIxlzNmH0GLTcM7ReOV6CCHKvSSjK433igs7RnL2+ sWBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aiDAuVFNTqDieRfxgbTiYbYD42OLD9sOlocc8uI46o0=; b=WwqHF+zuMQ+v9wdSvNTGxcv16fsXkUkmMR0xyy7tfnR1jxfgHQ2zn6M+oovKnG0QSL SBrM5VNnd5GCTbt2YOzmk62VYpmwCUctaPtREKfiIFe9fwjTSwOpacF6BjYHO0fVyarj xNUdobIZTHb/qZcMCXQPgprn117B6Ue93yNGkkaSoX0d9OwwBPVIVvqWUX2DYSgvrtcs IjP9Kg1TyPms/pW17+/qLKqL3tUJfKDdjaexdvW9f1fisBX8/RioMUGtP/YXsD7SXbms 5HsG6tV4mOT1e7FCX0CSWrywRkj7Z8ofHaL+bfajUkqObXweNZgLx0KDBq19tbJTSIG7 CLpw== X-Gm-Message-State: AKS2vOwp8NgpWV4KMBnHuKPVYN+I8wj7OmT39AP8kOqnPMt7jkvGQ1rq oS7O+kyHq13oUmmdlFo= X-Received: by 10.176.75.97 with SMTP id i33mr20111940uaf.149.1497979682572; Tue, 20 Jun 2017 10:28:02 -0700 (PDT) Received: from localhost.localdomain ([191.8.96.73]) by smtp.gmail.com with ESMTPSA id x2sm4922955vkd.35.2017.06.20.10.28.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 10:28:01 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure][PATCH 10/14] UBUNTU: SAUCE: hvsock: fix vsock_dequeue/enqueue_accept race Date: Tue, 20 Jun 2017 14:27:30 -0300 Message-Id: <1497979654-27251-11-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497979654-27251-1-git-send-email-marcelo.cerri@canonical.com> References: <1497979654-27251-1-git-send-email-marcelo.cerri@canonical.com> Cc: "K . Y . Srinivasan" , Dexuan Cui , Cheng-mean Liu X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1698425 Signed-off-by: Marcelo Henrique Cerri --- 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().