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 4EB5DA0C4E; Wed, 21 Jul 2021 02:17:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5DA340689; Wed, 21 Jul 2021 02:17:37 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2133.outbound.protection.outlook.com [40.107.93.133]) by mails.dpdk.org (Postfix) with ESMTP id 24EA04014E for ; Wed, 21 Jul 2021 02:17:37 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lyluh5mP26nsLrBrcHJYQVuIBt73HMX4a+mdQHxwftwJDiNlePkFzsFg6LOQaD/+8BGcIlFPAFVieD9rd32gLgwoGSYlG85bQ4/fo20XFfGvPBb1G7Kosus/ne2VFkDeljc7uzIr0ZfOdGOSwyo7EbcKUknOvsnnGYpJzhHfcXs1mlDY9LfQ2IrNm60AGEuoI4p/UgmNsC8NESTCot5Af1Ti2oqZMJwWxinqXzOHM+8eFskT5SPSJ6IAn0xJ0i9jkAlzHW2d9nIXG8LXVnHUJCfQtB5kZir1dmV4E55Oooy2A0tnXq2nRnEOqtSqsjtv+8WTRctZMjrE+H5i3jV3JQ== 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=wVYp7UPF82RAuBUA9BYcEXIKybqByWQ5duT7IpVQMdk=; b=axenmiRdkZZp18wCi3UF/Zw0Zg5LSHvwIiDGGahNoG+LMVfSuCEU0HvXX9B4RmbCEkCop7m2qBMj6nWaCjZDBjZhK/qr5jk4BtwH1cpEO2CE09SUyGCm7+Obw5ZXFItVfD/PwfcYDWw1MeBOwc61lbRjOxSGO5esqTnfTqdiMYQV/F+CXHUIfpz+85ZrbIWEbCm/M9i5DTpJ7AJklIIaozR6OxPnixJXUmkWRPbKEddr/nz2maPVBguyHfKHEdiISdTtt0wLd8aCwly0kPaslYdW51l4iy4Vg519v3TLGKp+zIhCVRY2JZaUR8+4Hp0pKTJfG7EvTnUWm2JkZZSDXQ== 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=wVYp7UPF82RAuBUA9BYcEXIKybqByWQ5duT7IpVQMdk=; b=Zoao3cE5ViuP4RwppL27MZMiUEODr8kJqngCnjdI4YpL5aijf1YRAvDbjvTi+6m8VPDYtx6DvB/zT5+wL9Wtlxic+RBe9x3Wh6N3Ugab7kBhoyV+/1TVk+ev6BP+sndlDe2aPTwTgEetSDJC2TwPaM5uOAL0l3K7YVsE6nAlhYs= Received: from BY5PR21MB1506.namprd21.prod.outlook.com (2603:10b6:a03:23d::12) by SJ0PR21MB2016.namprd21.prod.outlook.com (2603:10b6:a03:2aa::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.1; Wed, 21 Jul 2021 00:17:34 +0000 Received: from BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::d97f:36c9:1b1:5d07]) by BY5PR21MB1506.namprd21.prod.outlook.com ([fe80::d97f:36c9:1b1:5d07%8]) with mapi id 15.20.4373.006; Wed, 21 Jul 2021 00:17:34 +0000 From: Long Li To: Stephen Hemminger , jerb CC: "dev@dpdk.org" Thread-Topic: [PATCH] bus/vmbus: Fix crash when handling packets in secondary process Thread-Index: AQHXfXe80RHQrXHFrUyUiReB1FsB+atL/N4AgACS7vA= Date: Wed, 21 Jul 2021 00:17:34 +0000 Message-ID: References: <20210720145839.12180-1-jonathan.erb@banduracyber.com> In-Reply-To: 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: b46441c2-06c6-455c-c79c-08d94bdcf078 x-ms-traffictypediagnostic: SJ0PR21MB2016: 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: dp4D5/nvn1tvRyi5sps1lelUFILNgOpKiBiT9jUZWpGhKPwZOK5fCg/zSrTQXf10JzMiGJrRoUaY8ioPD5KRGXJzLHnCNi5QSTcl3r/2pbhIHBRn4YTT5L8dahFNvsr5BGAXm4icrgDjtmrW1UBMKsouQXpGsQIVY6le5ZjT4JIRRACT0j6xrcvtwoKNHoZwHTMejV+RP2MmIHOOfjIdqHkkPobeIaAVWSrH+USGRlP2Xck6nvaGC7/dNVBL2ZjjuCfKUD3EiWhqtD+QFA25fpxfJdHgpzeTceIDqtYDTxyuYmX2UFa2zi4FZMKThn/trxTBT1hGS5wMC601liaLkvyVLPKaiGHsak9R+Bx1BaFKclO0GWR/vy4Zl/k0iKeNQWwvk9CR87LdOFPfJWZYJcvXHvoL9zwc2MomAB2ttmpVOQ2VYFCN4EL2E+Z32SYxGYVLKHdx6d2vDwo9fZi8lSieTDmbIWyig+RT6UHUFTxzEObSCxOvI2AlqzrLa/5TXbpIec5EfvxxuAvi1pqweVCtmLrBh+PRk4IJkWrmhvKZ97uwGnfdOhggrliFTiZkRzIADx4O4A4qItpteDIPDgnObFiSeV3g9YBymUQB63MCqb52gIuk/NV51JgO87sYmxlLc3uFuzTCdk/Vig00ueAkDMs0KHIO/6eaeToLAKej51n+O/XJ3mtAcVEKMlLH1wiFuwuhfWlQ4xlGxV7b0w== 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)(9686003)(66556008)(76116006)(82960400001)(33656002)(508600001)(8936002)(66946007)(4326008)(55016002)(64756008)(316002)(66476007)(110136005)(8990500004)(8676002)(66446008)(52536014)(83380400001)(86362001)(122000001)(53546011)(2906002)(5660300002)(7696005)(38100700002)(6506007)(10290500003)(71200400001)(26005)(186003)(52230400001)(82950400001)(38070700004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lIl095J0URj5fi6YiPZuGXkFB1fq7cBfzq4f/GID+aaQzVI+lgMgWurlVI3T?= =?us-ascii?Q?r55r+aqG5PR5FjvSTVUAdPR6zS9GLqSjiEbxpuTHcC0YoM/2u0A710Xmp66T?= =?us-ascii?Q?XJatho4UJ5cmoHvsvp7zxqJA5LwCfn+94PfAOeY4jzJ7pvtlmhGo6bXpKKjz?= =?us-ascii?Q?EqupmewFCfBvaUuimpnW9/9M17BNo2NybgD1AKrnoDvHp1VJEqFDa4caaHOk?= =?us-ascii?Q?6/OHgaCb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oRlXy?= =?us-ascii?Q?BlTJCy2UWP9/ynjVtXXXJHXoEo1IaeG+tyMYhAGZ2z9ngksBzCKptnN5b9rR?= =?us-ascii?Q?aYyLT1tXNz8a6trWTOQYsUuweAdkaz9uvPLETw1sOzxGGdQXSeIk72hD2jZD?= =?us-ascii?Q?C5CTFGGKUwyoGLC4uqSvabhwxsQkkCuQLzcscDKPr2kV6LhEKmVrKThAMMYY?= =?us-ascii?Q?6kQ=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: b46441c2-06c6-455c-c79c-08d94bdcf078 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2021 00:17:34.7816 (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: p2A+0q2PM6fXxcTOH0xA/Lg1JuAN2nv2ZaI8mXXy1Nl6hr2GagpxlWDiP4a03kr5XHC3woNacnOQlWWiUPnmAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB2016 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" > -----Original Message----- > From: Stephen Hemminger > Sent: Tuesday, July 20, 2021 8:29 AM > To: jerb ; Long Li > Cc: dev@dpdk.org > Subject: RE: [PATCH] bus/vmbus: Fix crash when handling packets in second= ary > process >=20 > Looks good, minor comment. You don't have to check for NULL before callin= g > rte_free(). > Rte_free(NULL) is a NOP like free(NULL). >=20 > Sorry for top posting; but if you send to my Microsoft account you are st= uck > with what Outlook can do... >=20 > -----Original Message----- > From: jerb > 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 > 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. >=20 > Signed-off-by: jerb Looks good. This should also go to stable. > --- > 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(-) >=20 > diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h in= dex > 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..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 > -- > 2.17.1