Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbdHQMna (ORCPT ); Thu, 17 Aug 2017 08:43:30 -0400 Received: from mail-cys01nam02on0048.outbound.protection.outlook.com ([104.47.37.48]:16944 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750991AbdHQMn2 (ORCPT ); Thu, 17 Aug 2017 08:43:28 -0400 From: "Jorgen S. Hansen" To: Dexuan Cui CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , "gregkh@linuxfoundation.org" , "devel@linuxdriverproject.org" , KY Srinivasan , "Haiyang Zhang" , Stephen Hemminger , George Zhang , Michal Kubecek , Asias He , Stefan Hajnoczi , "Vitaly Kuznetsov" , Cathy Avery , "jasowang@redhat.com" , Rolf Neugebauer , Dave Scott , "Marcelo Cerri" , "apw@canonical.com" , "olaf@aepfle.de" , "joe@perches.com" , "linux-kernel@vger.kernel.org" , Dan Carpenter Subject: Re: [PATCH net-next 2/3] vsock: fix vsock_dequeue/enqueue_accept race Thread-Topic: [PATCH net-next 2/3] vsock: fix vsock_dequeue/enqueue_accept race Thread-Index: AdMWE/OcqyyawNZsSxaayApZ7QpUYgBQnVgA Date: Thu, 17 Aug 2017 12:43:23 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jhansen@vmware.com; x-originating-ip: [80.197.119.203] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR05MB2299;20:rThOAAINGtkIBe1xa4C1aA4aEloWaitdt9rU42EkBd6zKuuXjMnui4K2vTg1DsRp77fUWt9uxsukqetCszm9bBKOESj0gHOpOapbosuOXShI3JWh5bNdkPfBpSVy4X9BhFA3GMWXDHzJZRta61WbQQMcFlhL275z2w16VzPUk0c= x-ms-office365-filtering-correlation-id: 5394c528-cbec-4d89-ceff-08d4e56d8c91 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR05MB2299; x-ms-traffictypediagnostic: CY1PR05MB2299: x-exchange-antispam-report-test: UriScan:(89211679590171); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR05MB2299;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR05MB2299; x-forefront-prvs: 0402872DA1 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(24454002)(377454003)(189002)(199003)(101416001)(189998001)(106356001)(14454004)(7736002)(4326008)(105586002)(25786009)(305945005)(97736004)(54356999)(50986999)(53546010)(33656002)(76176999)(66066001)(8936002)(3660700001)(3280700002)(7416002)(3846002)(6116002)(2906002)(102836003)(1511001)(110136004)(68736007)(8676002)(2421001)(82746002)(81156014)(6436002)(36756003)(81166006)(77096006)(2561002)(6486002)(53936002)(5660300001)(6916009)(2950100002)(6506006)(6246003)(54906002)(99286003)(8666007)(83716003)(229853002)(2900100001)(86362001)(478600001)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR05MB2299;H:CY1PR05MB2217.namprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <6FA8E0297FF38E4881DFBF823706D562@namprd05.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2017 12:43:23.5987 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR05MB2299 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7HChaZG003836 Content-Length: 801 Lines: 13 > On Aug 16, 2017, at 12:15 AM, Dexuan Cui wrote: > > > With the current code, when vsock_dequeue_accept() is removing a sock > from the list, nothing prevents vsock_enqueue_accept() from adding a new > sock into the list concurrently. We should add a lock to protect the list. > For the VMCI socket transport, we always lock the sockets before calling into vsock_enqueue_accept and af_vsock.c locks the socket before calling vsock_dequeue_accept, so from our point of view these operations are already protected, but with finer granularity than a single global lock. As far as I can see, the virtio transport also locks the socket before calling vsock_enqueue_accept, so they should be fine with the current version as well, but Stefan can comment on that. Thanks, Jorgen