From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754129AbcEQIfK (ORCPT ); Tue, 17 May 2016 04:35:10 -0400 Received: from mail-bn1bon0146.outbound.protection.outlook.com ([157.56.111.146]:55264 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753435AbcEQIfF convert rfc822-to-8bit (ORCPT ); Tue, 17 May 2016 04:35:05 -0400 From: Dexuan Cui To: Vitaly Kuznetsov CC: "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "driverdev-devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , KY Srinivasan , Haiyang Zhang Subject: RE: [PATCH] Drivers: hv: vmbus: fix the race when querying & updating the percpu list Thread-Topic: [PATCH] Drivers: hv: vmbus: fix the race when querying & updating the percpu list Thread-Index: AQHRsBQyW1HgwOhmAkiGh+0dOLVbqp+8zMKQ Date: Tue, 17 May 2016 08:35:00 +0000 Message-ID: References: <1463461980-13401-1-git-send-email-decui@microsoft.com> <87r3d1drt4.fsf@vitty.brq.redhat.com> In-Reply-To: <87r3d1drt4.fsf@vitty.brq.redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=microsoft.com; x-originating-ip: [2404:f801:9000:18::4be] x-ms-office365-filtering-correlation-id: 677de4bf-fbc6-481c-3c4a-08d37e2e22a5 x-microsoft-exchange-diagnostics: 1;BLUPR03MB1412;5:IJEoRQvzdk0hzIFA4CCMoeLM1u9pwsijAICXGeD42O+PwtuUx3h68olAqA5HVqZOdVlw24z5TxwJM/HMwdZT0LV6LhrIjolV71F9HXFQq7Mm3CnKsuDg9EowOoaYJHD5Tc04I6HYAh3LJbcD6dx5Bw==;24:xz9NMTgS+obkJmhEafPOUy65q5W20H9kspVHrMtKeI139JJm3IsUouy4VZpedhdHVuAQcVGuh87Mh6grWFh7hupoxnGjeN8+3x6o1PPWJDI=;7:wdwsmANrRpkRjcF22GdtSntLu302CzrJKGTTAzplaNZ2cWGtrMlNgfsXHowOTGmitP8BFVyIa4JHn8gp+MvepJk2+M7XmVkIITbq43CqusV7Iuzk4jIiHa+VKWJndzRI2mPN0VMK0RbP+1Y6luw5AWEm/9V++ip9eCmCGAWnevwfVMWmPWAtamYta+qXsw0TS3XYWx0W9npEoQfNI7hJBg== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1412; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(61426038)(61427038);SRVR:BLUPR03MB1412;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1412; x-forefront-prvs: 0945B0CC72 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(57704003)(76576001)(10090500001)(10290500002)(10400500002)(74316001)(5003600100002)(5004730100002)(50986999)(5005710100001)(8990500004)(6116002)(107886002)(9686002)(19580405001)(19580395003)(102836003)(1220700001)(4326007)(3660700001)(3280700002)(110136002)(586003)(2906002)(4001430100002)(189998001)(8676002)(106116001)(99286002)(77096005)(86612001)(5008740100001)(2900100001)(2950100001)(54356999)(76176999)(122556002)(87936001)(5002640100001)(81166006)(8936002)(33656002)(86362001)(92566002)(3826002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1412;H:BLUPR03MB1410.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 May 2016 08:35:00.0158 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1412 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] > Sent: Tuesday, May 17, 2016 16:15 > To: Dexuan Cui > Cc: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; driverdev- > devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com; > jasowang@redhat.com; KY Srinivasan ; Haiyang Zhang > > Subject: Re: [PATCH] Drivers: hv: vmbus: fix the race when querying & updating > the percpu list > > Dexuan Cui writes: > > > There is a rare race when we remove an entry from the global list > > hv_context.percpu_list[cpu] in hv_process_channel_removal() -> > > percpu_channel_deq() -> list_del(): at this time, if vmbus_on_event() -> > > process_chn_event() -> pcpu_relid2channel() is trying to query the list, > > we can get the general protection fault: > >... > > > > We can resolve the issue by disabling the tasklet when updating the list. > > > > @@ -418,6 +413,7 @@ static void vmbus_process_offer(struct > vmbus_channel *newchannel) > > percpu_channel_enq(newchannel); > > put_cpu(); > > } > > + tasklet_enable(tasklet); > > Do we need to do tasklet_schedule() to make sure there are no events > pending? This is probably not a big issue as some other event will > trigger scheduling but in some corner cases it may bite. Same question > applies to the code below and to vmbus_close_internal(). Hi Vitaly, Thanks for spotting this! I think you're correct. I'll add tasklet_schedul() before the tasklet_enable() in the 2 places. Thanks, -- Dexuan