From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5593D43FF0 for ; Fri, 10 May 2024 09:28:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4A67B402F1; Fri, 10 May 2024 09:28:38 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2101.outbound.protection.outlook.com [40.92.99.101]) by mails.dpdk.org (Postfix) with ESMTP id A5A954025F; Fri, 10 May 2024 09:28:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iwuSr1bZL+Dv5CPCW8KT+GuNP2L+Oucw61tr0FkAau7ZQEAxS5OU5BADVR3oj6vEN+uqgafS8c6VGpbwu/f8fJdi8ZNt0cTSSZs9/MiFsluZp0pDYzJ84ZbhKCkIzu8hImI7Ouzxhoi23NHRJEhGPoTR0O8ksLk4eAQeQly8+9+eoVsD9R35OYKcHX3da6/IxuxAHb5a5h421tYYuVBx9oA4QgdWiW05XqgDTBJ1lTPI/Ryd9JdttJU9nOwofIpjUsI0ZA5Rgn00cMyqB56a8ZRlfvZ8RtjMwQu8PUJyqd1rPea04GG8IWoVJKENcX+2O9EMLZXkkf4EMRChM4EPRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ga1Z7EpafxpVopUzqF8UnYZDz4rDAtClBCtcGddLQGA=; b=DDr3jEsPx0jXIh2nRheIQ0KVc0uZUIrCLoZqrEiQhBkeUbo5Try1GbPibd4GuatQHIPQMVl35TfjAy1puW9nfPa1CBF8RB3xndErYUc00tmKDcuNsRIBP3d7d3+Cg8QDTcwZHdB0LLC2QD+/v7WUpZTbyHR2pDDB3GgF0DUTJ1nj8oqQ2bziIH25Wm8B4lL7eF5DzSW4RYagPpAPQisu5oJLTwxkrgVKEpYA1F8WuVRPap4gaC0oujjdY/XFKQHjGXC0f7P2oJiLyOefl6K8r+fV/OFVcKtoKCQB/7SMn7IBIsHPJ86ypDTA/Cw92+hR75907alIpkWBciIUSN/OiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ga1Z7EpafxpVopUzqF8UnYZDz4rDAtClBCtcGddLQGA=; b=B+35C1Ea4dmwudzLLIT1YJF3AIlwMtqyUZDLXTey2DXLAcy6llTylGDjaQvybqzGJqd6qHaGhKuZiK/sI09UwRNY2HF4iygItjwZo3JyyscqwAfyOlS9n+t5pQLapos4fic1sgXyRYcmsLp6hW1Iy80Jlosh6aX7QEXwFfkpXZPxbrnWDg6gfsavCW52rv9h0RwJwmEDR33LnPFpb3aimumxcCs9cAll4JZBXBp11gGWXj2OsFVdMzuZiQ5/sC4gF9WLtoF3HJANiS63CFt8TN176T2qBa0I1lyOJ6M4Pa524qfrYkjsnxEz5FrzflJi5hEoTAaEjOEQIvtQIGKTeQ== Received: from TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM (2603:1096:402:38::13) by TYTP286MB3927.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:180::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.48; Fri, 10 May 2024 07:28:32 +0000 Received: from TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM ([fe80::a92e:74bb:6df2:7ea2]) by TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM ([fe80::a92e:74bb:6df2:7ea2%5]) with mapi id 15.20.7544.048; Fri, 10 May 2024 07:28:32 +0000 Content-Type: text/plain; charset=us-ascii Subject: Re: [PATCH v1] vhost: fix crash caused by accessing a freed vsocket From: Gongming Chen In-Reply-To: Date: Fri, 10 May 2024 15:28:29 +0800 Cc: dev@dpdk.org, Gongming Chen , stable@dpdk.org Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Maxime Coquelin , chenbox@nvidia.com, chengongming1900@outlook.com X-Mailer: Apple Mail (2.3693.60.0.1.1) X-TMN: [arJWp1NwxifKH2n/sh4ZWp/82nb8ZdkB] X-ClientProxiedBy: OS0P286CA0047.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:9e::16) To TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM (2603:1096:402:38::13) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYAP286MB0649:EE_|TYTP286MB3927:EE_ X-MS-Office365-Filtering-Correlation-Id: 159b7487-d147-4586-58ec-08dc70c2cb7d X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3430499023|440099019|3412199016|1710799017; X-Microsoft-Antispam-Message-Info: oFj9CCL0WUTM414S7nw1BFKTNFhgAesrzxb5ub8Aykheq40MHH0E+K9McVTCT1eht0P5YyFlHhbU+hSCCmFU5yLAB/4/eQ5QLq947KAP8DLPvnl4/YHZe7FR7skGZzaiFpOQytbe5G8dgR97lGd5SoFLBe82AqhV3Qc5uELxDny8bASDQ5HaXEj7bE+dATSiyBX7ca0FWs9y8+yFVZncuPECYKb4P4OflKpmBxx3a6hYH2ZvdGjdAVsZGozhoarRuiTAPFNWzlvTr3yY3XPmwFeHB1nZXNIr5MZIaM4j54TvQBgqmmxnsVMFNY8dHd1PkXkOsYPkb7+lXXyYJFQ9WEJj9gN1Ne9x8S/nmi4HRII+RK8gV2okOtztwRVguAV5cdSvHX8fqmJ3G1YspYJnXqnjwj7unr2J0kioplIl/AKfn/SXzaVLOldW+bLwL8K2Rs+LCOR245ZblSNt9VBxRjI9/fFzHnyFK9VRtz6YIUUBvOiAPIMv2WfNXXJw8fbeDT83fNSNdUc6Hn09n8XTzLjpSpaDAJEz9A2sGO5KDAUyuDzTYqQYiHEpwb2xV46BwoAOJL/oH8G5el/v6UgYU97RqF1DWnWmxZHPMHJwImSdW0whdN+J9lXMZW6Jr6BO X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?pjI5a1TmmGzBnC18Cksdgvj4tNQm7EOuRX0FPUg1SfTogMKKxi6gLcUtP+t4?= =?us-ascii?Q?8aA1EQNJrGnb2xb/i9W94HqESuAQMmwe/TlAEamHQgjlx+cBqOuA0zr5PgNj?= =?us-ascii?Q?vjFSH6VSdHRBnWquUN4VzCgkEeUo2gIZB+guBXIHF3yVa2BNyGJcCs6Fhqvx?= =?us-ascii?Q?DiFNSAaagODT0niCrQKTIgyztihPmztnFoJWujBdB6PR2trKA81G21CedUX/?= =?us-ascii?Q?kkhOTnmFWH4vN/eLP8V2DsJex41F3iz15zbcw2bXv9PzWNmzoMRlkYR8ERWe?= =?us-ascii?Q?JUAKmd0OkJqlasOTZXB4w4E6f+V0kvOL/bM9vmFt64aOa06kZAPQFsHsyUWQ?= =?us-ascii?Q?fzffE/vcj1pPBruw6KLGVYhErwEgfKfpbBWpzfDRLcdP7IR/jYDEjt8PRhCL?= =?us-ascii?Q?2p5bILlALMJBR9K59vWPeTpZH0xp54nNAJISph7eNjqvcNqEJ2ulofdlXwh6?= =?us-ascii?Q?7Sv86pigJK03Y8uyeKpvWXwhLvnW0Hqsvdstw03E9JhEnhsJgDOKIJ4IagX7?= =?us-ascii?Q?/uQFT2xVXZuc1J/BzfaqgHkIIa5fCqNBkqVHSkKbtfrhifJXvzNuG5qJF8Fn?= =?us-ascii?Q?j/4cB25v0EBzoMVH24sFWghjo2Yp8V7iTJ9uAuYsisuyeFAbt2/6mzX8iF2z?= =?us-ascii?Q?znT6vW5tYbC0MeskGL4cRhocIPfw6oowedXHuO4Ub9FBqmchqUh3oDpFC+0Z?= =?us-ascii?Q?L808g4fLNO+tWd7/Fs70yVJl5MCrL36L6q2tTi9jAU5l21RpnNp8EFPD/1ew?= =?us-ascii?Q?1RCr3+9u0/Acz03OSF3/i8PGNotwUmYfFbnshvyQl+6BRvlFQWYtGoYkw6mi?= =?us-ascii?Q?NKulBKlG8qv+xS0hDafSJMfTNZzUjSl5VjWoOVYAeNfA9clFNW4NHSIuxFzc?= =?us-ascii?Q?xpd/ZgIUQB9IvvWjnOL0tsClBFFm/16vCo1CGR8j6iE/Se2xWnE59JJciA+G?= =?us-ascii?Q?3wERcLejdFJCpCSWwn3Gq1fMfX78BA50vLMGyGE+wjzIkM9wNYrt5s0Ph8nH?= =?us-ascii?Q?yghRBqjOpQgh5kESaVteS1Wd5AoPqjYHpq4Fqwy3o3g7iN81Qf3aF18Bb829?= =?us-ascii?Q?xcaay/Ih3Oo/SaNFz1tTPq95dIcaCSV5QrUjc8G5EwSdqvh6nArIyLG7S+6I?= =?us-ascii?Q?sjGy5I1BULvpLQvwojZgddMGUst7GqDSlKAilVsFFMyixXqfDoAtcZZOxCnx?= =?us-ascii?Q?B0OUk50D5zFi1X1e4xuxORUlEBbEmvKY6E9QEXEapG5ciUwJLwM8mmWfPJYP?= =?us-ascii?Q?SfeRIpUHzEuESa+/wbvU?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 159b7487-d147-4586-58ec-08dc70c2cb7d X-MS-Exchange-CrossTenant-AuthSource: TYAP286MB0649.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2024 07:28:32.1030 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYTP286MB3927 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi Maxime and Chenbo, Do you have any suggestions for how to address this? Looking forward to hearing from you! Thanks, Gongming > On Apr 3, 2024, at 11:52 PM, Gongming Chen = wrote: >=20 > Hi Maxime, > Thanks for review. >=20 >> On Apr 3, 2024, at 5:39 PM, Maxime Coquelin = wrote: >>=20 >> Hi Gongming, >>=20 >> It's the 9th time the patch has been sent. >> I'm not sure whether there are changes between them or these are just >> re-sends, but that's something to avoid. >>=20 >=20 > Sorry, there's something wrong with my mailbox. > I will send a v1 version as the latest patch, but they are actually the s= ame. >=20 >> If there are differences, you should use versionning to highlight it. >> If unsure, please check the contributions guidelines first. >>=20 >> Regarding the patch itself, I don't know if this is avoidable, but I >> would prefer we do not introduce yet another lock in there. >>=20 >> Thanks, >> Maxime >>=20 >=20 > I totally agree with your. > Therefore, initially I hoped to solve this problem without introducing > new lock. However, the result was not expected. >=20 > 1. The vsocket is shared between the event and reconnect threads by > transmitting the vsocket pointer. Therefore, there is no way to protect > vsocket through a simple vsocket lock. >=20 > 2. The event and reconnect threads can transmit vsocket pointers to > each other, so there is no way to ensure that vsocket will not be > accessed by locking the two threads separately. >=20 > 3. Therefore, on the vsocket resource, event and reconnect are in the > same critical section. Only by locking two threads at the same time > can the vsocket be ensured that it will not be accessed and can be > freed safely. >=20 > Currently, app config, event, and reconnect threads respectively have > locks corresponding to their own maintenance resources, > vhost_user.mutex, pfdset->fd_mutex, and reconn_list.mutex. >=20 > I think there is a thread-level lock missing here to protect the > critical section between threads, just like the rcu scene protection. >=20 > After app config acquires the write lock, it ensures that the event and > reconnect threads are outside the critical section. > This is to completely clean up the resources associated with vsocket > and safely free vsocket. >=20 > Therefore, considering future expansion, if there may be more > resources like vsocket, this thread lock can also be used to ensure > that resources are safely released after complete cleanup. >=20 > In this way, the threads will be clearer, and the complicated try lock > method is no longer needed. >=20 > Thanks, > Gongming