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 C6A62A0C4F for ; Tue, 27 Jul 2021 00:16:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B6996410F7; Tue, 27 Jul 2021 00:16:53 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2104.outbound.protection.outlook.com [40.107.244.104]) by mails.dpdk.org (Postfix) with ESMTP id EF0D4407FF; Tue, 27 Jul 2021 00:16:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhifge3Nh4RzZ2c7Lq30tRQhDOrPWzX1zDl/Dpu/6BPcC+HkjYZrG+v37TyxZ6jG6+TCTc6aFEdOLUwFB9pGzAMpERlTnL/j7CirCYzbuMtL4Auizh+aHM+gvTz+/s+o0B+UrWMWuJscVm09LZDarj2GJtM/9/XYLilMA7swrC5Kk9kg5nFGYHA019iq2QIX3wTWPZVzifBoLcCGG5KQDCi6q6uM6MqDwemgShhNJwqoQ8dxSVdmHPcF7RCL2OHoi8OrIaDvVdaqZhlvuWa1pKnUT6mOBdAZb7y060ECDoc8UHCxZb6h4l1wJzdIFvRBUovYwfsBySHrtCP0pKqYOw== 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=gepvfeLqNIaZV1v1QkvU8yrVPRWyQ65Rux2Ejw7sHHc=; b=ToRT5mABd8/iACAjwtSyHXMkp0WHhqHn4ovib3qdrGIMyRDLc1oSeexh8NvL7h0chHFwXVqHcrvp+7Os/0jENAn5BZsTfbm4JiuTXdwXlkMZwW/IJfWOhy6c2g3aBdjbbr1sKn+I5i6bz+pTRKrxMMRmyngIGXx4/0dBq70PKR6brqrQRGVR0mlsj50qGgfJ3uOYaFaVaYPY124z71hSWukTZkGgjEVX8b+7rdDai71VwWw3PGtZje/BAUWUh7yJpw1DLe3YteFi+FQBjKLclNE/Tk+45rJPA0WnrVphyV86UFmt74vo3iIv/wI/ZbQx8mijhGXyHNhIqIk0OdT4mA== 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=gepvfeLqNIaZV1v1QkvU8yrVPRWyQ65Rux2Ejw7sHHc=; b=AIpwGxWbps6UpDwdo6s8Fex2j0+gAwg5Gsz0T09HEf3+8EYfAlv4PQM6ZtdtryaBPAln6nZM9Xp0qscfeaf06PJ3ehTJLXOlQhvBIO4I8Kd0/jCgjhVrZoOqdtPpqv5kisvYbxsqtBjFkYAMQC5VXGOAwFU0Xt7H2CQklEc34Zs= Received: from BY5PR21MB1506.namprd21.prod.outlook.com (2603:10b6:a03:23d::12) by SJ0PR21MB1982.namprd21.prod.outlook.com (2603:10b6:a03:292::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.2; Mon, 26 Jul 2021 22:16:50 +0000 Received: from BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::69e1:f3dd:4987:8b64]) by BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::69e1:f3dd:4987:8b64%5]) with mapi id 15.20.4394.004; Mon, 26 Jul 2021 22:16:50 +0000 From: Long Li To: Jonathan Erb , Stephen Hemminger CC: "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH v2] bus/vmbus: Fix crash when handling packets in secondary process Thread-Index: AQHXgj/5re0yRIwOMkiz0jbUl3USsKtVyxeg Date: Mon, 26 Jul 2021 22:16:50 +0000 Message-ID: References: <20210726170040.25155-1-jonathan.erb@banduracyber.com> In-Reply-To: <20210726170040.25155-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=6460f3fc-8c6b-42b4-8077-4be575cc5db8; 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-26T21:47:14Z; 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: 4817e20b-ebfb-4f00-e590-08d9508310c5 x-ms-traffictypediagnostic: SJ0PR21MB1982: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: AlvdtiryNhDLbRAmiKAYQ1mZri/GYJoCPRpZBBzdva35WISg7YRTuGnDZbbesoZKrTK4Rw6seWJ/9+WNxrQ0eHPIHTEHAF22XxaQbGugwgv2pRKlerpNrthozCE/L3qGfGSE+ZIWKXnE5orl2I6vzHEGWXn/3V+a2yA4AArTqqhLAGxCPIpGmm4gIXzrpPpE1pbZFFSN7O4p5kBgYzAMO/3lS48HGsk0q+cvCRCBytXUPuJn0iOsOzY6USWS9jw4cfWu/c3BSJHIBUShT6UEwx3TYG3Y0iu6ijXz/hUAwnNCtGU6Itm0oQLzTMtVbfQIPJKpB1c34dRZ8PRHTUh3uN01FM7k0cEjBKQ61tvAq8Jl2PD2TzCyp2AadzrvDa0aRjjoJAFXoOUzPMDvB6fbgXD18lnI6ZrngtWvV09/tiot/pZODrRKLst9I5Gz16DkJCXPgYVr69AFvqrC+s5WEbqvR6o3i9F8FwJ2QFVrcg06EYkxsIu1nFXQm1FvtdoMV27tWsh3v2aZmJZJD3UN9jhgxwgo3nuZEM3rkjVRtiaWOkVXIsHpw/czbLYDrWAfN+BlZFBXUUZ0EJrhO3AdVIBLBl4rtkhPaXk4SMc2ywvGSklCBGir7h7bMnCRXX1X3eCwkr3wlvFdfo7pkPgMx9RYzIzJzdPb6utRebhyrDj062hwasVwg5Q3c9eVsf02HNwak35Td3jT0jYWK1gSmg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR21MB1506.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(4326008)(82950400001)(2906002)(10290500003)(66556008)(82960400001)(38100700002)(6636002)(186003)(508600001)(122000001)(8936002)(52536014)(26005)(8676002)(66946007)(9686003)(64756008)(66446008)(316002)(33656002)(55016002)(66476007)(8990500004)(71200400001)(5660300002)(54906003)(83380400001)(76116006)(6506007)(86362001)(110136005)(7696005)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4QCw21MozDf8UVqVTRbFTgWH7dhlOATL0v2ylqv08RLJPGrHDeU8zi8gmqIA?= =?us-ascii?Q?l2lYyWh1mJubjri3WPAMVT/qttLU755uYHJB5LAOvTiiEOufC4IjKy5M5AGP?= =?us-ascii?Q?LFy9OnaK49q/gZC7lUwnMPp8iy08TrJCSVnmkeU/tk3pc3gRNMkiiH2tTYEr?= =?us-ascii?Q?adnnESy4YI/rwb+tJDAzMEwrdLwQq0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NRxDz1GGgyCvu1o2kvc+/W9kELUfUtxldkl3czxaPcwBWWkaNLE1h?= =?us-ascii?Q?FNjdzVRlzZl+8JuRLPcvG3jC4Kc91wWpd2JsW9sZLI/EOffp95X55bkwQ1BO?= =?us-ascii?Q?C+sfSktndR92u62Us8kEEyJ6uvCC+7iLxSN0mRkxTxZAZxpoYBfxY+HVswQy?= =?us-ascii?Q?iPUnh7K4W3XahM6p5zhIkNj23HSI/n5q73VVENlqNPDyv3fkv4wyFpgyKKTa?= =?us-ascii?Q?BEA=3D?= 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: BY5PR21MB1506.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4817e20b-ebfb-4f00-e590-08d9508310c5 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jul 2021 22:16:50.0495 (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: TLm/bgzaEnl4QYL7eetFiTvYGwfEeAg5ARUkD7Zc9gWUYXyKTmsLUy3dJNg5qhfszYMyZDr9Bwy/hHX/WtNYjQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB1982 Subject: Re: [dpdk-stable] [PATCH v2] bus/vmbus: Fix crash when handling packets in secondary process 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 Sender: "stable" > Subject: [PATCH v2] bus/vmbus: Fix crash when handling packets in > secondary process >=20 > Have secondary processes construct their own copy of primary channel with > own mappings. >=20 > Remove vmbus_channel primary ptr from struct mapped_vmbus_resource > as its not used. >=20 > 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. > Cc: stable@dpdk.org >=20 > Signed-off-by: Jonathan Erb > --- > v2: > * Remove unnecessary check for NULL pointer before call to rte_free() per > reviwer comment. >=20 > drivers/bus/vmbus/private.h | 1 - > drivers/bus/vmbus/vmbus_channel.c | 4 +--- > drivers/bus/vmbus/vmbus_common_uio.c | 14 +++++++++----- > 3 files changed, 10 insertions(+), 9 deletions(-) >=20 > 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_channel.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 > *device, >=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..83c56b6fa2 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; > } Looking at this closer, I don't think it will work for subchannels in the s= econdary process. The code after is:=20 STAILQ_FOREACH(chan, &dev->primary->subchannel_list, next) { if (vmbus_uio_map_secondary_subchan(dev, chan) !=3D 0) { VMBUS_LOG(ERR, "cannot map secondary subchan"); return -1; } } Because at this time, the primary channel is just created, "subchannel_list= " should be NULL. The secondary process ends up running without subchannels= . In the primary process, "subchannel_list" are populated when it calls hn_= dev_configure(), so it is good. Sorry I didn't spot this earlier. The best way to fix this is to use rte me= mory functions for allocating vmbus device. In this way they can be proper= ly mapped to the secondary process. But rte memory functions are not availa= ble at the time vmbus device is probed. I haven't been able to find a good = way to fix this. Will keep looking. Thanks, Long >=20 > @@ -211,8 +213,10 @@ 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) { > + rte_free(dev->primary); > return vmbus_uio_unmap(uio_res); > + } >=20 > TAILQ_REMOVE(uio_res_list, uio_res, next); >=20 > -- > 2.17.1