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 7C94041E63; Thu, 11 May 2023 10:26:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C8B542D62; Thu, 11 May 2023 10:26:38 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 1137542D5E for ; Thu, 11 May 2023 10:26:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683793597; x=1715329597; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IDJ2Kukqir2Y5S+HQEjgcnIFjg9iNL+Mf/gGwVMAPj8=; b=MHWUVns0VykXVI+Xm8R4I2hTy0KNxMHeHUXhBZTCFzm6lTU40ckm0Z2M Ugu4m7U67bWbtGLegXmmJAeYVnmhlyNDqgvY0S6mjUxA8VQQTxE13uLws V+gg434oZ10CdTtmmHVE9Jzo6MDIEmiXTIdJhN3AF0yf7oRgFyHHc71ya CeBZ1vfR7t/LJiRnxfkk7Vn34zLmVUdSXM9TPRu+DZuK9hTGtipHftY+0 SbfUeMGospIS+pMc0nlxomrLIY8Yh/IpJ4itdb5StMG27IfBgEcVqZc3C 3/gs8F9fArpm7A4KIGrKzJnyUfXwMewFSeRReDEzC8i54YJtLMf4CZasf w==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="347905076" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="347905076" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 01:26:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="764643761" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="764643761" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga008.fm.intel.com with ESMTP; 11 May 2023 01:26:36 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 11 May 2023 01:26:35 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 11 May 2023 01:26:35 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Thu, 11 May 2023 01:26:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WfqfbfdR3K3UTv93wY8o64DKe5mO13ma5kx1r8cwFQ7mff+bW3dZWD+rrsR5Jy6ZI/jyYKqawqnegCQ4icit0+CWqFyO2GUdM2y3VQPlqPnKCup2/0k0+GrGLQjIfcBJosSH+3WieJYNwfnhD+og7nCTabIsVDRY6faS2xkXKUw0wP/77I60bPBm8qBGELqcPdSzUL54fvHyTYeYeTX+nYEcWBLHcuqsaHZb8ZjlKGglAZ/9oaZ2CIVHyMrjTFv/IrHwoZDeJ/8wWZQZlJif1yIWgHNoPBXNOLEMj0/Vc07kw4Gr8GtDNhmxDjs09kR7b8zQkjI7wcwZhT58owR4IQ== 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=u6ylzgvF81fZFsT+E60JcSTE4Y/qy7OMCQZrVdypv4Q=; b=dQSF4Tn1XuPc4XktOnneDYaY0+a2Be/JJJeoFmwG0eoOixYQbFbD2cyGmy5pQ8xzRs0WR/feqBeK3vMUPHGssZhyFTdmqPlKpzSgtl3uTMKvs4FGkwjnsrwRMMiPrMhu7tiPkwQ74uDUqJU1l52mjnaicAUC/xCap/ydK/etkoHaD0CBxPhCi8p7PTgS02S576HqOSzhF+cYfUmoqUVGiP6+ZwplDR+AwdWvBYbd76pCD0tCe6nJwY4dUjptad97B6i9rkWS/cgKoGWLl24zn9zNRcxI19jcUGSJiCqVEXt7fmYSsOjt4MPauNdV37lCNAdciwemq2lmHwrBuo+sLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by CH3PR11MB8093.namprd11.prod.outlook.com (2603:10b6:610:139::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.36; Thu, 11 May 2023 08:26:28 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::e427:f0a6:8472:d0f6]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::e427:f0a6:8472:d0f6%6]) with mapi id 15.20.6387.019; Thu, 11 May 2023 08:26:28 +0000 From: "Xia, Chenbo" To: suntianyuan , "maxime.coquelin@redhat.com" CC: "dev@dpdk.org" Subject: RE: [PATCH] vhost: fix crash on vhost-user client port deletion Thread-Topic: [PATCH] vhost: fix crash on vhost-user client port deletion Thread-Index: AQHZW73RinxUzwIa5UaKw5pf5FqJ7K9VDMuA Date: Thu, 11 May 2023 08:26:28 +0000 Message-ID: References: <20230321062352.48460-1-suntianyuan@baidu.com> In-Reply-To: <20230321062352.48460-1-suntianyuan@baidu.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SN6PR11MB3504:EE_|CH3PR11MB8093:EE_ x-ms-office365-filtering-correlation-id: ee64cde1-d216-49b0-50f6-08db51f96aaa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WF/KycQbYhZnpQKbCxYDJY5ujkQlp8WCocaTD4N+F8rj276N1jrpt2PJMVwcDkq3qBeSzY45PuZcXOwpPDDosTmnUxlbSD23ryvehJD6uHV70+lkP+8X9PqE37jbmuORN84BSp/Kuta7KyBT2xvDI7MW+xGc9OYdNIGaZPPHVUtLqLob8ZQb8M5wj2zzM7J7qcQMQGuPUD+ktQxEJGM5DAvJlrsD7iztTXfDOR9jdn3m25rN+Hg82zIGTDSpQVrHvZAveXNwlCgIM4TpqdWKJRkQzs0XQrZnlHv3yevkC9hHZNG3oaz39ZiMSq4ikJZjMMUhaDOSWBxkopo0Z++0pNkje3oiBw+UjXjLENOArFQ0oxe6nbo0tKNcSNZ2wdAbQGK2Dqj3ggiJrNo/HILCPKsmd9uK/rfyqrTFTFc0SMyDAoUoMe9kiP8MMikObVonsKBMMzvuf9dQQTuV/aVDinziGylrlZWSeuDYPiLSfXXAaPteQvFQ+8YeAOYNTSMMWZnAm3ih1RaPR3yMtZGttyzbBjCxcO3VILniOsCNlFpIIoen9bXxQ++Lyklwso+UZi6a6flsUG/yGrM1VYaQT4UNdXnWf55JsIBxvp8ByoOahvEjKYMUavYZbWHCa14L x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(366004)(136003)(346002)(376002)(396003)(39860400002)(451199021)(966005)(4326008)(76116006)(66946007)(66556008)(66476007)(66446008)(64756008)(478600001)(7696005)(316002)(110136005)(33656002)(86362001)(83380400001)(26005)(186003)(53546011)(9686003)(6506007)(71200400001)(8936002)(8676002)(5660300002)(52536014)(2906002)(41300700001)(55016003)(82960400001)(38070700005)(122000001)(38100700002)(46800400005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?F0rCpfcrkEsTAYBEp8hi89hMDQfQdLtz4tXrrOBmvzVMSOrfjZN07Q/EcWD9?= =?us-ascii?Q?opXgkZqlubErBd9jjU+/AeLlMU6lNQhSmpmzfL8bMuBjb4zKV3zz5FLP0w6p?= =?us-ascii?Q?v914HtV/5qPftUSjMRyqnNv7XeGuFVa41lIJIn0GW6vTUsErL9cqNbVn1/xY?= =?us-ascii?Q?4YXIqnBM5DHe85yo+EoEjviVa0w+OJZEMquzu6yv/WxxiMQGWmh793ZkKGWy?= =?us-ascii?Q?qb+Dy8dRBJUgOtUUqG/iQiJd5m+NyYC1i3OqSwCutNYc0/d4ewzoYKi3hjpm?= =?us-ascii?Q?QXCxJmRCcdubThHFsGIU1xnNlCLfbdhtT5ez2nS/IvpDSlc3PbGhgwhxJJtY?= =?us-ascii?Q?8tKb3EHXd4dDYfFnXdj7Ia5nFyRXYtduXBfUeamnsbsx9dgoTcQx2fZYm98o?= =?us-ascii?Q?yQu8tMfgXT8t85XKfMEln9PE/i2mL/euLPC5kxTInnxnwCKqTpo1EUZetbOs?= =?us-ascii?Q?LwJVHMkYg/HJP9JFgns8vCr0S9y93PynSHTetDGHAwhpPO4zYVYo/gGDMFwp?= =?us-ascii?Q?/RA0LBzESTitErXmqaA2IjTyYZd4T6knWRzox67LfYX6PXeU26naIxr/+FYi?= =?us-ascii?Q?tsCiYm6PXQ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qr7YrQpph?= =?us-ascii?Q?pj7q2OrlBjZZSWwqCQQQzXQm6KA3zhe5Seh+yOdqVm6eSpiHsZw02sf3okq+?= =?us-ascii?Q?sSDoZrpQeykjsYsdI+gCMh2rF5upQvPQxsvGi7Ch?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee64cde1-d216-49b0-50f6-08db51f96aaa X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2023 08:26:28.0890 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4o9KVPo8+a03jCnzvnI2an9P1oPU3wO+6ygJhf51vEtGUaAbifLq8+r4sWBFtvqGahLhNv11OBPODHjOI3fuXg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8093 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Tianyuan, > -----Original Message----- > From: suntianyuan > Sent: Tuesday, March 21, 2023 2:24 PM > To: maxime.coquelin@redhat.com; Xia, Chenbo > Cc: dev@dpdk.org; suntianyuan > Subject: [PATCH] vhost: fix crash on vhost-user client port deletion >=20 > The rte_vhost_driver_unregister() and vhost_user_read_cb() can be > called at the same time by 2 threads. reconn may be added back to > reconn_list by vhost_user_read_cb() after rte_vhost_driver_unregister() > removed from reconn_list. Then rte_vhost_driver_unregister free vsocket, > cause vhost_user_client_reconnect access invalid vsocket memory. >=20 > Timeline is as below: > rte_vhost_driver_unregister thread excute vhost_user_remove_reconnect > vhost_user_read_cb thread excute vhost_user_start_client add reconn to > reconn_list > vhost_user_read_cb thread free conn > rte_vhost_driver_unregister thread cannot find conn, then excute > vhost_user_socket_mem_free > vhost_user_client_reconnect access invalid mem, crash >=20 > Signed-off-by: suntianyuan There are several coding style issues. Please check and fix: http://mails.dpdk.org/archives/test-report/2023-March/374602.html Thanks, Chenbo > --- > lib/vhost/socket.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c > index 669c322e12..72c776d15c 100644 > --- a/lib/vhost/socket.c > +++ b/lib/vhost/socket.c > @@ -1046,8 +1046,6 @@ rte_vhost_driver_unregister(const char *path) > pthread_mutex_unlock(&vhost_user.mutex); > goto again; > } > - } else if (vsocket->reconnect) { > - vhost_user_remove_reconnect(vsocket); > } >=20 > pthread_mutex_lock(&vsocket->conn_mutex); > @@ -1080,6 +1078,8 @@ rte_vhost_driver_unregister(const char *path) > if (vsocket->is_server) { > close(vsocket->socket_fd); > unlink(path); > + } else if (vsocket->reconnect) { > + vhost_user_remove_reconnect(vsocket); > } >=20 > pthread_mutex_destroy(&vsocket->conn_mutex); > -- > 2.32.0 (Apple Git-132)