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 F3FF1A0C50; Wed, 21 Jul 2021 13:38:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 82D3F4014D; Wed, 21 Jul 2021 13:38:17 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2139.outbound.protection.outlook.com [40.107.92.139]) by mails.dpdk.org (Postfix) with ESMTP id C0F7F40689 for ; Tue, 20 Jul 2021 17:28:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KjVbT5cQj9U7FX9TPb5b/DKWPXpw82XB6mpqHcmmUNZZ6d1Y0b2uW11RD2i9fFP/kbfpOo1deh37kNj7qyruhi6mav5AW8lc9sOm73ZWnUS+z+Pv1LlOG2V3k2KRVLVt3lkAc7E7m8tSdNFIneKlxyVHnIRPknkn/Hdmz2br/6xpMEAckwRfbJEShc3YYTW+mdpirm+Rt5EcpRKMZJciKExXZSwXfjzOBhVHyQGAtKDdfKTbpnb2oBmXW+ozG2KiUpclexQwJRbgOPPMG4cWCE1+xTQmAbFWCxvg2i/7T4PjiPiga6pLsdUc/GoiuJq/Nr/s8jIf6Vfd+EL2LmuGkA== 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-SenderADCheck; bh=zLqYt672KMIB5uauJWRX9El8Qyhy8lTMu7a7KMphXbI=; b=kTpCCvMjSp8A9ucl4s+3gxb+tRUdzGZ4Mxzq9vpZ2s748uFvREk8GBlMI0nGKEdWjV4rLH4oAG/vgMhAOlIxVE6sAwgWN8JJwqwGUW3JrE3/9X7NNQImJnl0TMhC/IoQT0mAa1+NmPpRUm2BkPG11GKaYf1uDBX/YHBObkeZ5MeFtEEr2mS/j5E11Kgydj+4YEA7Z5rHY4Z6dMk+EIoo/XzV5sLGkiSBNxLmpCnq6fAZII7ovWQkHMNvjJhH0TzHuk/ZrIIJxqCaD9UrKNTQ8obeOZQj3mWejhpbHSKzejOazmBHGSAuUr82kc/MY4Qu2LoePs9BwA2W0m0nTXhGeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zLqYt672KMIB5uauJWRX9El8Qyhy8lTMu7a7KMphXbI=; b=dqXZCP6aGcbsErvkox5gbk2ccmdyq3NhIU2I95zVxiMytrrxnYKflMuUbAJMf4iVKw7QFNVj9TMUEse8M23R0386WMxq9mACJ9T5K8ymJgZg96O9HX26y6uAFkf6mo0HZmhGNfKNbw5EJsmxZ1pqRGT1v3CLHZdw7qbT+Tj6LTU= Received: from MW4PR21MB1907.namprd21.prod.outlook.com (2603:10b6:303:71::8) by MWHPR21MB0173.namprd21.prod.outlook.com (2603:10b6:300:78::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.2; Tue, 20 Jul 2021 15:28:34 +0000 Received: from MW4PR21MB1907.namprd21.prod.outlook.com ([fe80::dff:779b:e14b:8086]) by MW4PR21MB1907.namprd21.prod.outlook.com ([fe80::dff:779b:e14b:8086%3]) with mapi id 15.20.4331.010; Tue, 20 Jul 2021 15:28:34 +0000 From: Stephen Hemminger To: jerb , Long Li CC: "dev@dpdk.org" Thread-Topic: [PATCH] bus/vmbus: Fix crash when handling packets in secondary process Thread-Index: AQHXfXe9l47rq6EvBkapkQyr6FO84atL/CSw Date: Tue, 20 Jul 2021 15:28:34 +0000 Message-ID: References: <20210720145839.12180-1-jonathan.erb@banduracyber.com> In-Reply-To: <20210720145839.12180-1-jonathan.erb@banduracyber.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=472793fa-8b93-4eac-893d-605e0a3adb2e; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2021-07-20T15:25:57Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 304fd104-e4ff-478b-a77f-08d94b9309d2 x-ms-traffictypediagnostic: MWHPR21MB0173: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:660; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Jy82EXYboQA5MiV7cXKEQp5Zf7Qvc3/QgreYWC572GgKVcU4V8r860Hf8vpEltiF0CN+pon8LmOvTQ0K/nBR+ZQ9SLW1goSLN0AfTPHmw5ct8CFbWwU5VhTQDGHpaMbKkpf7mMo6ZrBckdoUSWcgxd3ftr/4XaRbd2eAIpys4W9In6FtcWM5Fl6Wam2bN41tH0HESUaeVYp5Mzes+LMDH95NOgCDQBX/RvnDAr7Smh4/dKu/aOBhjACZLmlnz/sTd67TVWEIdAmhnXdjShA5D1RRiCl9spDbN8st1NI9Qg/MHEcryue362tbBVGQCtcYB1nmt1CefYjmjjA5FoArNYUsKGmt4KeNYb1KdBrx47j4LHZCybOm/KSFwy+udU2WVZwVNnSNyQXa5OPb+79CldVnYycYHW8lJ0LEgNjrfp8xn8//UUm6IURWXe7WEP8rDF+YLUxyXcKvUy/h4UNSoeg/KVH4OfbmSeS/DV/YUL/bKAYYDHQkDW0rTB74j5dCVmv1/Ok6vR4L4DqI0fhD9NwUwOxNtbIJsjnpOBBlzUAOBA/qaYGz2kUfzQoZz7K/Hzp9IaMJAA7MXuLbVLJ5vxRS6Z3DaS4EPgqKQWlSAf00+V5Izcqq1JigU0Vj7ZAcycwmrDOpClgwNudsdu/LqA9bBXDpzWmzeVPheCqZTxdTig8Uxuj5L8cI+9ZOlxF2MbtghFjHa/hDzsaE9nlmoA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR21MB1907.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(9686003)(6506007)(8676002)(33656002)(4326008)(52536014)(82960400001)(55016002)(186003)(6636002)(83380400001)(10290500003)(7696005)(82950400001)(66446008)(64756008)(26005)(8990500004)(53546011)(508600001)(66556008)(76116006)(110136005)(66476007)(2906002)(5660300002)(316002)(71200400001)(66946007)(8936002)(52230400001)(122000001)(38100700002)(86362001)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?TKs7HrOEVOvPi58NJUc+S4mbC15VxjUtes0IueW+DPSnYXmZR86QovB3gP0K?= =?us-ascii?Q?QvaXhGvuTmS+2AkD5nYNejvcLsa/56iSSV9oKFbC0rfpaOkN5KXsoycNBzt1?= =?us-ascii?Q?CHkE0hGoUMCFbp7ViZ9Kpf1E51nFTp7eNeKigH0NIyLUQLNAnwrhdUhrJbL9?= =?us-ascii?Q?tShE/P9zG6Rk8Uem/bvdReRAy1M3Y9Vk2SsTtzAPZx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L+GzI2jpMUmvyhpFqulfIItF04KQrNVJYipiGvdkHWu87?= =?us-ascii?Q?OJs6RT7LDV2CfqyJgGkwuHqtbCM6PTXe3Jp1p26rURpbZ3inoMDEE9bH9ub5?= =?us-ascii?Q?zV7SOBXKkW6gN79TrutWlzQhn3lWfrh44yhLMQGX06tvxG3i/xdUBgLqO/OG?= =?us-ascii?Q?HR8fZiViln89xZfZigBNFm7nLtEy8lFI/W4U9dV271Q0vj2bVCc8l9DVmU+P?= =?us-ascii?Q?AHTw3xUMKvlUitAW/heh3Yjl?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR21MB1907.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 304fd104-e4ff-478b-a77f-08d94b9309d2 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jul 2021 15:28:34.6164 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: n0fAQptwrj98B720t4FIfeSUbtlXxg5uDBEPcB9myn5U83YE0vwg747iq+cqwzLP8LJVq+tiyhTOHijldxbT3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0173 X-Mailman-Approved-At: Wed, 21 Jul 2021 13:38:17 +0200 Subject: Re: [dpdk-dev] [PATCH] bus/vmbus: Fix crash when handling packets in secondary process 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 Sender: "dev" Looks good, minor comment. You don't have to check for NULL before calling = rte_free(). Rte_free(NULL) is a NOP like free(NULL). Sorry for top posting; but if you send to my Microsoft account you are stuc= k with what Outlook can do... -----Original Message----- From: jerb =20 Sent: Tuesday, July 20, 2021 7:59 AM To: Stephen Hemminger ; Long Li Cc: dev@dpdk.org; jerb Subject: [PATCH] bus/vmbus: Fix crash when handling packets in secondary pr= ocess Have secondary processes construct their own copy of primary channel with own mappings. Remove vmbus_channel primary ptr from struct mapped_vmbus_resource as its not used. Populate virtual memory address "addr" in struct rte_mem_resource for secondary processes as netvsc will attempt to reference it thus causing a crash. It was initialized for primary processes but not for secondary. Signed-off-by: jerb --- drivers/bus/vmbus/private.h | 1 - drivers/bus/vmbus/vmbus_channel.c | 4 +--- drivers/bus/vmbus/vmbus_common_uio.c | 15 ++++++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 528d60a42f..746212bd5f 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -42,7 +42,6 @@ struct mapped_vmbus_resource { =20 rte_uuid_t id; int nb_maps; - struct vmbus_channel *primary; struct vmbus_map maps[VMBUS_MAX_RESOURCE]; char path[PATH_MAX]; }; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_ch= annel.c index f67f1c438a..119b9b367e 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -351,10 +351,8 @@ int rte_vmbus_chan_open(struct rte_vmbus_device *devic= e, =20 err =3D vmbus_chan_create(device, device->relid, 0, device->monitor_id, new_chan); - if (!err) { + if (!err) device->primary =3D *new_chan; - uio_res->primary =3D *new_chan; - } =20 return err; } diff --git a/drivers/bus/vmbus/vmbus_common_uio.c b/drivers/bus/vmbus/vmbus= _common_uio.c index 8582e32c1d..7b9a8ef434 100644 --- a/drivers/bus/vmbus/vmbus_common_uio.c +++ b/drivers/bus/vmbus/vmbus_common_uio.c @@ -69,8 +69,10 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) fd, offset, uio_res->maps[i].size, 0); =20 - if (mapaddr =3D=3D uio_res->maps[i].addr) + if (mapaddr =3D=3D uio_res->maps[i].addr) { + dev->resource[i].addr =3D mapaddr; continue; /* successful map */ + } =20 if (mapaddr =3D=3D MAP_FAILED) VMBUS_LOG(ERR, @@ -88,9 +90,9 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev) /* fd is not needed in secondary process, close it */ close(fd); =20 - dev->primary =3D uio_res->primary; - if (!dev->primary) { - VMBUS_LOG(ERR, "missing primary channel"); + if (vmbus_chan_create(dev, dev->relid, 0, + dev->monitor_id, &dev->primary)) { + VMBUS_LOG(ERR, "cannot create primary channel"); return -1; } =20 @@ -211,8 +213,11 @@ vmbus_uio_unmap_resource(struct rte_vmbus_device *dev) return; =20 /* secondary processes - just free maps */ - if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) + if (rte_eal_process_type() !=3D RTE_PROC_PRIMARY) { + if (dev->primary !=3D NULL) + rte_free(dev->primary); return vmbus_uio_unmap(uio_res); + } =20 TAILQ_REMOVE(uio_res_list, uio_res, next); =20 --=20 2.17.1