Received: by 10.223.164.202 with SMTP id h10csp660784wrb; Tue, 14 Nov 2017 07:39:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMbyKAXtmRul+rPQHY6ZFk3E/nyDFu3VvdRtiRrYPr32tKmv9SWnyvGpVbXDr6EkZjsVbeX9 X-Received: by 10.84.163.75 with SMTP id n11mr12689202plg.287.1510673978592; Tue, 14 Nov 2017 07:39:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510673978; cv=none; d=google.com; s=arc-20160816; b=aEJ2agP40qxiGCYdcyhW+cOvC1q/ztoHYQgIi1owKDAk8+XBdhyLV3X21+mLH2oAiK H4aVNL2TtmICjdOEWSIjBQa8g7zR2DuRhzDCremP2AGez4BtTDUfM8sfkYG66J+ukqdX XynV0FKJ8T/AdrKpkkvzgwRCf5pGr0YT2dT9Ga57TVV1Oe6XNxwdVPc/HAruQ0Cd+JN/ lecONT9Irbe2jmvB7VnY3hUmovNUgz8ZpfJBo2sHC0woVWOrdkYs+8lSMAeVwMzR8rLd EdxUG990cDykMoRepqonK8plkmEB48wfTcc1PUa5ekEqvPc6AQYHPeO5YaXIMlPCOA4D u2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=7KCtFq29+oukhbpKnos5W2OxecJqErSHxjXyLZEU0yw=; b=0EEeF3h0BzCieydN9kbZZnt+nw8DamOpiUw7JaJ10JbLqFlrXfvDYOJuZi1pu+G63o ZOW82Hiq2gO2dNbBl94TxTuMp1wxSHeiXPCWscK3vk0H1PHE2Se4V+LXUysC8CtPmKN3 K3OWtsH6xDQL8wfOCLLGgI5UlpFjKZmVZl1Vj5npbiHqdrADh6HBCq8GG0kZXaQBXp76 GBVt2iH0pbSVxsxu2UNjoyJvMW3T5CUtHRG/BO2J7dbNkGOstLC2Xs428Dgakg6D12A0 U5pvu4L23pkF8er/1jrQpXOVXGeYwgx6flZXwGa1fRDIc6R3EaIaAypx0nkut5U/7O8m dvOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r28si17575595pfk.101.2017.11.14.07.39.26; Tue, 14 Nov 2017 07:39:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=exchange.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754965AbdKNNym (ORCPT + 88 others); Tue, 14 Nov 2017 08:54:42 -0500 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:50340 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754852AbdKNNyg (ORCPT ); Tue, 14 Nov 2017 08:54:36 -0500 Received: from linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id EbeheoPPa3w7hEbehemwtw; Tue, 14 Nov 2017 06:53:35 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv.com with local (Exim 4.89) (envelope-from ) id 1eEbeh-0000nV-2h; Tue, 14 Nov 2017 06:53:35 -0700 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: "K. Y. Srinivasan" , stable@vger.kernel.org Subject: [PATCH 2/2] Drivers: hv: vmbus: Fix a rescind issue Date: Tue, 14 Nov 2017 06:53:33 -0700 Message-Id: <1510667613-3035-2-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1510667553-2991-1-git-send-email-kys@exchange.microsoft.com> References: <1510667553-2991-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfFSd4m58B/f0TuJAlII4ZmPe9jME/gEMdno0ZnhuqtjjJ3MhSjmuwWN+qpoCkAK7VvGAyMO+axvVuPRvTXHk1arHf0KId6TzXFw6YmFc4mzvuVoWqanu etj6TCb7TVfVBw8lAAk4Zd2o4uU1wKecdpRYykq4HMH1rxlP74v2IgoXs0ZugnNnnydgx+ZI/7A9GG7f0CO9+9Iv1lwRh4oEQkRq44/6kj3aejYRuLmaGQfC t4dh0IVrYak2ddXzq8j8otH+Fp1p73w9kLZGKRd/nqsjnswuYfsTTcBKR/oZZm4GB4Zdg7+eM6JpPcedprDy3jqrB7/RTaBTKMdXs/LsJQ30yh27iNslonLB RePk8bO5Kv7XodZqaZhix3LKd5YIckD1CP5vSfVCRUa7fOA2Qeq/5N+nW8DYtIhix4AgEpXdBzdtY6a3p0YBvVsAUY60xn/wueOgCPakm9nDax73KcmHxyA5 of4nnmY/iXSjY9fs/kib0Eb/xSuv4i1f2XtSdDUZDDM8zzwgv8TcbP9fAPSgT23X9/IvzeN29K/8iqvCVESQ6CjeEFbMhj7vGs8Kgw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: K. Y. Srinivasan The current rescind processing code will not correctly handle the case where the host immediately rescinds a channel that has been offerred. In this case, we could be blocked in the open call and since the channel is rescinded, the host will not respond and we could be blocked forever in the vmbus open call.i Fix this problem. Signed-off-by: K. Y. Srinivasan Cc: stable@vger.kernel.org --- drivers/hv/channel.c | 10 ++++++++-- drivers/hv/channel_mgmt.c | 7 ++++--- include/linux/hyperv.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c index 19f0cf3..ba0a092 100644 --- a/drivers/hv/channel.c +++ b/drivers/hv/channel.c @@ -659,22 +659,28 @@ void vmbus_close(struct vmbus_channel *channel) */ return; } - mutex_lock(&vmbus_connection.channel_mutex); /* * Close all the sub-channels first and then close the * primary channel. */ list_for_each_safe(cur, tmp, &channel->sc_list) { cur_channel = list_entry(cur, struct vmbus_channel, sc_list); - vmbus_close_internal(cur_channel); if (cur_channel->rescind) { + wait_for_completion(&cur_channel->rescind_event); + mutex_lock(&vmbus_connection.channel_mutex); + vmbus_close_internal(cur_channel); hv_process_channel_removal( cur_channel->offermsg.child_relid); + } else { + mutex_lock(&vmbus_connection.channel_mutex); + vmbus_close_internal(cur_channel); } + mutex_unlock(&vmbus_connection.channel_mutex); } /* * Now close the primary. */ + mutex_lock(&vmbus_connection.channel_mutex); vmbus_close_internal(channel); mutex_unlock(&vmbus_connection.channel_mutex); } diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index ec5454f..c21020b 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -333,6 +333,7 @@ bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp, return NULL; spin_lock_init(&channel->lock); + init_completion(&channel->rescind_event); INIT_LIST_HEAD(&channel->sc_list); INIT_LIST_HEAD(&channel->percpu_list); @@ -898,6 +899,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) /* * Now wait for offer handling to complete. */ + vmbus_rescind_cleanup(channel); while (READ_ONCE(channel->probe_done) == false) { /* * We wait here until any channel offer is currently @@ -913,7 +915,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) if (channel->device_obj) { if (channel->chn_rescind_callback) { channel->chn_rescind_callback(channel); - vmbus_rescind_cleanup(channel); return; } /* @@ -922,7 +923,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) */ dev = get_device(&channel->device_obj->device); if (dev) { - vmbus_rescind_cleanup(channel); vmbus_device_unregister(channel->device_obj); put_device(dev); } @@ -936,13 +936,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) * 2. Then close the primary channel. */ mutex_lock(&vmbus_connection.channel_mutex); - vmbus_rescind_cleanup(channel); if (channel->state == CHANNEL_OPEN_STATE) { /* * The channel is currently not open; * it is safe for us to cleanup the channel. */ hv_process_channel_removal(rescind->child_relid); + } else { + complete(&channel->rescind_event); } mutex_unlock(&vmbus_connection.channel_mutex); } diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index f3e97c5..6c93366 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -708,6 +708,7 @@ struct vmbus_channel { u8 monitor_bit; bool rescind; /* got rescind msg */ + struct completion rescind_event; u32 ringbuffer_gpadlhandle; -- 1.7.1 From 1584732893526258589@xxx Wed Nov 22 02:50:58 +0000 2017 X-GM-THRID: 1584732893526258589 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread