Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932316AbbBDHm5 (ORCPT ); Wed, 4 Feb 2015 02:42:57 -0500 Received: from mail-by2on0115.outbound.protection.outlook.com ([207.46.100.115]:28192 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751383AbbBDHmy convert rfc822-to-8bit (ORCPT ); Wed, 4 Feb 2015 02:42:54 -0500 From: Dexuan Cui To: Vitaly Kuznetsov , KY Srinivasan , "devel@linuxdriverproject.org" CC: Haiyang Zhang , "linux-kernel@vger.kernel.org" , Jason Wang Subject: RE: [PATCH 2/4] Drivers: hv: vmbus: do not lose rescind offer on failure in vmbus_process_offer() Thread-Topic: [PATCH 2/4] Drivers: hv: vmbus: do not lose rescind offer on failure in vmbus_process_offer() Thread-Index: AQHQP9L9IDsUaeYEOU+NtTapwERKKpzgG+Fw Date: Wed, 4 Feb 2015 07:42:36 +0000 Message-ID: References: <1422982839-3948-1-git-send-email-vkuznets@redhat.com> <1422982839-3948-3-git-send-email-vkuznets@redhat.com> In-Reply-To: <1422982839-3948-3-git-send-email-vkuznets@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [141.251.55.69] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-EOPAttributedMessage: 0 Authentication-Results: spf=pass (sender IP is 206.191.230.4) smtp.mailfrom=decui@microsoft.com; linuxdriverproject.org; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:206.191.230.4;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(438002)(51704005)(377454003)(13464003)(2501002)(6806004)(19580405001)(86146001)(19580395003)(1511001)(55846006)(50986999)(54356999)(76176999)(66066001)(22746005)(22756005)(46406003)(47776003)(33656002)(92566002)(2421001)(104016003)(50466002)(87936001)(2656002)(46102003)(2950100001)(2900100001)(2920100001)(106116001)(102836002)(106466001)(86362001)(86612001)(77156002)(62966003)(97756001)(23726002)(79686002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB0844;H:064-smtp-out.microsoft.com;FPR:;SPF:Pass;MLV:sfv;LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0844; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004);SRVR:CY1PR0301MB0844; X-Forefront-PRVS: 04772EA191 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0844; X-OriginatorOrg: microsoft.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2015 07:42:50.2239 (UTC) X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=72f988bf-86f1-41af-91ab-2d7cd011db47;Ip=[206.191.230.4] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0844 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3299 Lines: 97 > -----Original Message----- > From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] > Sent: Wednesday, February 4, 2015 1:01 AM > To: KY Srinivasan; devel@linuxdriverproject.org > Cc: Haiyang Zhang; linux-kernel@vger.kernel.org; Dexuan Cui; Jason Wang > Subject: [PATCH 2/4] Drivers: hv: vmbus: do not lose rescind offer on failure in > vmbus_process_offer() > > In case we hit a failure condition in vmbus_process_offer() and a rescind offer > was pending for the channel we just do free_channel() so > CHANNELMSG_RELID_RELEASED > will never be send to the host. We have to follow vmbus_process_rescind_offer() > path anyway. > > To support the change we need to protect list_del in > vmbus_process_rescind_offer() > hitting an uninitialized list. > > Reported-by: Dexuan Cui > Signed-off-by: Vitaly Kuznetsov > --- > drivers/hv/channel_mgmt.c | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c > index eb9ce94..fdccd16 100644 > --- a/drivers/hv/channel_mgmt.c > +++ b/drivers/hv/channel_mgmt.c > @@ -152,6 +152,7 @@ static struct vmbus_channel *alloc_channel(void) > spin_lock_init(&channel->inbound_lock); > spin_lock_init(&channel->lock); > > + INIT_LIST_HEAD(&channel->listentry); > INIT_LIST_HEAD(&channel->sc_list); > INIT_LIST_HEAD(&channel->percpu_list); > > @@ -308,6 +309,7 @@ static void vmbus_process_offer(struct work_struct > *work) > struct vmbus_channel *channel; > bool fnew = true; > bool enq = false; > + bool failure = false; > int ret; > unsigned long flags; > > @@ -408,19 +410,33 @@ static void vmbus_process_offer(struct work_struct > *work) > spin_lock_irqsave(&vmbus_connection.channel_lock, flags); > list_del(&newchannel->listentry); > spin_unlock_irqrestore(&vmbus_connection.channel_lock, > flags); > + /* > + * Init listentry again as vmbus_process_rescind_offer can try > + * doing list_del again. > + */ > + INIT_LIST_HEAD(&channel->listentry); > kfree(newchannel->device_obj); > + newchannel->device_obj = NULL; > goto err_free_chan; > } > + goto done_init_rescind; > +err_free_chan: > + failure = true; > done_init_rescind: > + /* > + * Get additional reference as vmbus_put_channel() can be called > + * either directly or through vmbus_process_rescind_offer(). > + */ > + vmbus_get_channel(newchannel); > spin_lock_irqsave(&newchannel->lock, flags); here we get the lock. > /* The next possible work is rescind handling */ > INIT_WORK(&newchannel->work, vmbus_process_rescind_offer); > /* Check if rescind offer was already received */ > if (newchannel->rescind) > queue_work(newchannel->controlwq, &newchannel->work); > + else if (failure) > + vmbus_put_channel(newchannel); Here in vmbus_put_channel(), we try to get the same spinlock -- dead lock. -- Dexuan > spin_unlock_irqrestore(&newchannel->lock, flags); > - return; > -err_free_chan: > vmbus_put_channel(newchannel); > } > > -- > 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/