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 B6101A0C4A; Tue, 13 Jul 2021 11:11:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3BE93411BD; Tue, 13 Jul 2021 11:11:52 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id DB7464069E for ; Tue, 13 Jul 2021 11:11:50 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16D96JYe011188; Tue, 13 Jul 2021 02:11:49 -0700 Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam08lp2175.outbound.protection.outlook.com [104.47.73.175]) by mx0a-0016f401.pphosted.com with ESMTP id 39rvu5j8wv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jul 2021 02:11:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MXghmoypas11kZpuBSW4eW/uL1/yv1WUeBQG+SO42Ift6ow5BbgGWG2DlIBMqQoymjRoN5colmg3MFj9bsoEM4SOTh4owyyYD+scuZAZai2lnHEvVi40QRhwis/fYf+19gFTh2evrx3elavbgN+ZxmT49eWVZhYrMC9rbOVYfMtfx/nSUO9J8tBGmpGn6Iu9c8RryOTIaKkJogC8bLQno4Nglpmh6db6P1oYXvrETUXDfoEhl3F/lWLGZP+MZUkY1qYQFYgDs0oeCXfdw9TgGFNBd/0Yj+cdGItIrdrnrAFWZ+W8Fs6XOn8URDqSZdwOfRG5JK6FPKLjXh99e66Y3A== 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=wEFSBsMU9v3+CF5aAuK/tWWs1WkwrxyDBLl+T5uZ35Q=; b=OvzuMe2QzHPikvaQv/HVj+XhXq46ICCP3Z+4AHvI+Mz2/QkJYigiZvD6JyWGmIadFSxG6Ujk9zLh+LphPm1ZC23X+jxIslXob+4Ksn4qkDoubiWfzCEBcudxJhUMr6MeYXuLtH3mF1W0PYjerxG1BNXeDBMOSYdXJi3PxL51/rQOWicmsx2afbxGQr18F4tHeFDMGD3OTMHTbj+D8vcEnefaGHzsE/dgmFDteqq6vOYF+ngGU/7YrkDcOVsnrb9Jqkbnm9Vp9sfxdQ8eepPOTx9dGmIzgus52uOSGrJGHXNFpGMluH/N2VHcGCl6J5VmA595BIdr3UO26f9qRafAgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wEFSBsMU9v3+CF5aAuK/tWWs1WkwrxyDBLl+T5uZ35Q=; b=XZ4p/dCK2f2hqylaPUpd3LqyVrR16ZDLdax+6r/fGnyHtg4YoisibrXOoWMtZMf7u6+8uUXLZscv8lR8zRjSs1/uz68/N3eFpBbFRX1Ze0kZc304PKAXG/r1cx0Sz20PEKEsBMkgVUQyQ03ZCo54t95O6/dIJtSHlCB3O6Etj3w= Received: from CO6PR18MB4484.namprd18.prod.outlook.com (2603:10b6:5:359::9) by CO1PR18MB4667.namprd18.prod.outlook.com (2603:10b6:303:e6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 13 Jul 2021 09:11:48 +0000 Received: from CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::1455:9a67:a6e7:e557]) by CO6PR18MB4484.namprd18.prod.outlook.com ([fe80::1455:9a67:a6e7:e557%7]) with mapi id 15.20.4308.027; Tue, 13 Jul 2021 09:11:47 +0000 From: Akhil Goyal To: "Gujjar, Abhinandan S" , "dev@dpdk.org" , Jerin Jacob Kollanukkaran CC: "Power, Ciara" Thread-Topic: [EXT] [PATCH] test: fix crypto_op length for sessionless case Thread-Index: AQHXba4gpBGYGYGTHkSKS3XIMoCFn6s3liwQgAGVJQCAB4V+gA== Date: Tue, 13 Jul 2021 09:11:47 +0000 Message-ID: References: <20210630124637.2987722-1-abhinandan.gujjar@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=marvell.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 13c60d38-efa9-4a8f-8168-08d945de3e2f x-ms-traffictypediagnostic: CO1PR18MB4667: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: f3zBdxFJcezwdVPTBjwT6ge4Gd2KhxyKJeQNqLNi9C8hI2bQ7PTxuWm0Mp4+04von3ZLeF4wsrTS+igGdaw2s/5o9cf/iOCnGBLJOpsSnUa2unJOMGuaumpkah0AWOAetAH7MuY736XBbDzmbj2Yt6+GeY+p9Js6FaE/ryeMmAaftm2VjKuti5fYQMyJtPSvym/kQ7O9bzdj4sfBQnPxSb/64Z3annVVf3vdfG/4XKW5+3NoNwHUDpujOoGzUKjZiOGDh220Xf/1Irr3fknNFuF0c9VlqQ5dCGBt3KDcRfw2mYfj52yGFFwIReS+jbfYOGI13PBW6ksPru6RklyNBFSPsJpOILm/copoIMj4t6cQwHRITVbzIAVtiErbbPRiwUGELUxDTsFAhqL91rpsQCgO30YcmpblwAY9JLZIYC5cDF2XcuK5PWq3OLOH6Ti7k0PNTUtfrph4ppx1zLcwkMIPZu8LaUL0BC2sFk52LvejjFLrS2t0GWSCgZLdW9JkqRwlmoEWAt1ZcoKiOkqxP/Z7H7SQ/n0yx16eKrv8aHReyYmWESmO6CyG56Iu+wGOY5jEhU2ce61bTP5Jze4f3MyVlhzYiJMkIR87BopwWEy3q7HWhaUBrA0EMSs8w6PwhE0G06mEOu8AtBBX2tP28g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR18MB4484.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(39860400002)(396003)(366004)(376002)(136003)(86362001)(122000001)(7696005)(55236004)(6506007)(110136005)(83380400001)(478600001)(316002)(4326008)(38100700002)(26005)(186003)(33656002)(9686003)(8676002)(52536014)(71200400001)(66946007)(5660300002)(2906002)(66446008)(8936002)(55016002)(76116006)(64756008)(66556008)(6636002)(66476007); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?k5N9e0v0Fs8WaVT8jb6Hsz6t956wPkA6aplheO2TPzIgCPbHJ5WXwQuOWSlo?= =?us-ascii?Q?YxPUQekumDhTp5Yba3R4jnp9sqNyjxZY1X+CzLz4W66Oho3y3XZuqa8u001g?= =?us-ascii?Q?QQT/VDhBkf1A6B+1Z4VhIRgMorZU/suBj3rXU57Tc4gasjzna0VlEkBX6PI/?= =?us-ascii?Q?c6M/EU4WgSSnWabJC7mhtg6wPKEPIAHPSHv22GoyF+dZ/+fY1VNR98d6FsLv?= =?us-ascii?Q?bEB/qrRXulfq1bnne6MbknRB81bwRDnhqBXT43pFDpIv0Sh6MIkRxn8iZOrX?= =?us-ascii?Q?hbEX3Dq/u7hqL/en0z/UKwoIurPfEyfNDu3ynbbXsDvB1j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Zo/J86RHj6iIkv+cfir5mAub6NHX6f5X0XnqwynTiRkBq?= =?us-ascii?Q?DgMjVh3NpskTnYGzShIkZqLH3xCM4Obzd8eDcoodbeXsoq+NiZVaQTbivP7G?= =?us-ascii?Q?nCbvbRQjT03YEuet7zrjnMKQ?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO6PR18MB4484.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13c60d38-efa9-4a8f-8168-08d945de3e2f X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jul 2021 09:11:47.6469 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: K/dFsSEqh3pRNIkhaP24BGOHMuf+4kCkUt7GP+bJFpSi1gOm6lkxMA//JTr3KHzDgOCV81BIswxwOtfLySerxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR18MB4667 X-Proofpoint-GUID: WWpA1sYkgxawiZUSWFlaLzVUOy0v3VLK X-Proofpoint-ORIG-GUID: WWpA1sYkgxawiZUSWFlaLzVUOy0v3VLK X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-13_03:2021-07-13, 2021-07-13 signatures=0 Subject: Re: [dpdk-dev] [EXT] [PATCH] test: fix crypto_op length for sessionless case 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" Hi Abhinandan, > > > > > Currently, private_data_offset for the sessionless is computed wrongl= y > > > which includes extra bytes added because of using sizeof(struct > > > rte_crypto_sym_xform) * 2) instead of (sizeof(union > > > rte_event_crypto_metadata)). Due to this buffer overflow, the > > > corruption was leading to test application crash while freeing the op= s > > > mempool. > > > > > > Fixes: 3c2c535ecfc0 ("test: add event crypto adapter auto-test") > > > Reported-by: ciara.power@intel.com > > > > > > Signed-off-by: Abhinandan Gujjar > > > --- > > > app/test/test_event_crypto_adapter.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/app/test/test_event_crypto_adapter.c > > > b/app/test/test_event_crypto_adapter.c > > > index f689bc1f2..688ac0b2f 100644 > > > --- a/app/test/test_event_crypto_adapter.c > > > +++ b/app/test/test_event_crypto_adapter.c > > > @@ -229,7 +229,7 @@ test_op_forward_mode(uint8_t session_less) > > > first_xform =3D &cipher_xform; > > > sym_op->xform =3D first_xform; > > > uint32_t len =3D IV_OFFSET + MAXIMUM_IV_LENGTH + > > > - (sizeof(struct rte_crypto_sym_xform) * 2); > > > + (sizeof(union rte_event_crypto_metadata)); > > > op->private_data_offset =3D len; > > I do not understand the need for this patch. > This is patch provide fix for segfault at the end of > event_crypto_adapter_autotest() > RTE>>event_crypto_adapter_autotest > + ------------------------------------------------------- + > + Test Suite : Event crypto adapter test suite > CRYPTODEV: Creating cryptodev crypto_nullCRYPTODEV: Initialisation > parameters - name: crypto_null,socket id: 0, max queue pairs: 8 > CRYPTODEV: elt_size 0 is expanded to 336 + ------------------------------= ------------- > ------------ + > + TestCase [ 0] : test_crypto_adapter_create succeeded > + TestCase [ 1] : test_crypto_adapter_qp_add_del succeeded > +------------------------------------------------------+ > + Crypto adapter stats for instance 0: > + Event port poll count 0 > + Event dequeue count 0 > + Cryptodev enqueue count 0 > + Cryptodev enqueue failed count 0 > + Cryptodev dequeue count 0 > + Event enqueue count 0 > + Event enqueue retry count 0 > + Event enqueue fail count 0 > +------------------------------------------------------+ > + TestCase [ 2] : test_crypto_adapter_stats succeeded > Segmentation fault (core dumped) >=20 > > Event metadata is copied after private data offset, and this patch is > changing > > the offset value. > > > > You changed the value of len =3D iv_off + max_iv_len + metadata_size, b= ut > > metadata is copied after this 'len'. See this rte_memcpy((uint8_t *)op = + len, > > &m_data, sizeof(m_data)); > Op_mpool is created with element of priv_size =3D DEFAULT_NUM_XFORMS * > sizeof(struct rte_crypto_sym_xform) + MAXIMUM_IV_LENGTH. > Whereas for the "sessionless" length is set to " uint32_t len =3D IV_OFFS= ET + > MAXIMUM_IV_LENGTH + (sizeof(struct rte_crypto_sym_xform) * 2)" > Whereas, IV_OFFSET =3D (sizeof(struct rte_crypto_op) + sizeof(struct > rte_crypto_sym_op) + DEFAULT_NUM_XFORMS * sizeof(struct > rte_crypto_sym_xform)). >=20 > So substituting IV_OFFSET, len =3D (sizeof(struct rte_crypto_op) + sizeof= (struct > rte_crypto_sym_op) + DEFAULT_NUM_XFORMS * sizeof(struct > rte_crypto_sym_xform)) + MAXIMUM_IV_LENGTH + (sizeof(struct > rte_crypto_sym_xform) * 2). > Which is a way ahead of the boundary which causes buffer overflow. >=20 > When memcpy is executed -> rte_memcpy((uint8_t *)op + len, &m_data, > sizeof(m_data)); > The m_data will overwrite the beyond the boundary. Hope this clarifies th= e > need for fix. You are setting len =3D sizeof(rte_crypto_op) + sizeof(rte_crypto_sym_op) += 2 *(sizeof(xform)) + IV_LEN + m_data_len And then copying mdata at end of 'len', which is not correct. Here, len alr= eady include mdata and you are copying mdata after its designated space. Ri= ght?=20 IMO, len should be set as IV_OFFSET+IV_LEN only. > > > > I do not agree with this patch, am I missing something? > > > > > /* Fill in private data information */ > > > rte_memcpy(&m_data.response_info, &response_info, @@ > - > > 424,7 +424,7 > > > @@ test_op_new_mode(uint8_t session_less) > > > first_xform =3D &cipher_xform; > > > sym_op->xform =3D first_xform; > > > uint32_t len =3D IV_OFFSET + MAXIMUM_IV_LENGTH + > > > - (sizeof(struct rte_crypto_sym_xform) * 2); > > > + (sizeof(union rte_event_crypto_metadata)); > > > op->private_data_offset =3D len; > > > /* Fill in private data information */ > > > rte_memcpy(&m_data.response_info, &response_info, > > > -- > > > 2.25.1