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 444D242999 for ; Thu, 20 Apr 2023 18:57:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3800141141; Thu, 20 Apr 2023 18:57:00 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2079.outbound.protection.outlook.com [40.107.7.79]) by mails.dpdk.org (Postfix) with ESMTP id 4297B40687; Thu, 20 Apr 2023 18:56:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EzDyEA8y5tTUxTFX/BZBsAKPXyAy0vKw8vIxJ70NhEU=; b=kv4yY8H0NEXamdGKA6SMx7alte3cfLTPZpzfx2tB96hl07MW+4hTNWFgB4aRt/3OlPJiJY1c4d5OYKRNCrOsoyUAqPef63cCIg121/6lpl18aLpZf8Fwll977brRP5ZsAUyQLsvptK2vQuJ4bLgZIGd4Yivi+pClyrhLSnEwALM= Received: from AM6P195CA0046.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::23) by AS8PR08MB7308.eurprd08.prod.outlook.com (2603:10a6:20b:443::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Thu, 20 Apr 2023 16:56:46 +0000 Received: from AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:87:cafe::4c) by AM6P195CA0046.outlook.office365.com (2603:10a6:209:87::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.24 via Frontend Transport; Thu, 20 Apr 2023 16:56:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT036.mail.protection.outlook.com (100.127.140.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22 via Frontend Transport; Thu, 20 Apr 2023 16:56:45 +0000 Received: ("Tessian outbound 99a3040377ca:v136"); Thu, 20 Apr 2023 16:56:45 +0000 X-CR-MTA-TID: 64aa7808 Received: from 67156d69e285.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8FDB7A6D-F2F5-440D-86AB-94481F2B0E10.1; Thu, 20 Apr 2023 16:56:40 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 67156d69e285.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 20 Apr 2023 16:56:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j84B/HTMs9rQNZoeMz/7sNixhVv7iCr8soYKMFl/S+3Uz5x+mxN3lcyDPHkyUovwoRbAU+8vmNDl9yow23cioalagHfWRLT86NxnY7oI1m7edafpYQz1Cqj5/CxSrQ7XjsMIE3p0v6wlvCM79Vr35y0i85KtwT+dUnskI/akqk2MK107zYjsdDa5yb478hIgKNiLXMft4bS/qF3Mhjp/JA5K0TVkD+bPQ1mFrBHd8eFLJqRTDb7O7AZZAKY33v0D9ON1v9aa8l1vpxXw2V66j5EfTUK3SM8SSDjwE9v00pf/YErgJ15JCPfxhJ65m6Xms55SsNF915VXl6Pmcgi12A== 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=EzDyEA8y5tTUxTFX/BZBsAKPXyAy0vKw8vIxJ70NhEU=; b=MA7qbDX+KUjjau/Asp8RhAmL6sMsQXtdPf7DsFqY5+2KDCPqnWt6IAOu/DIOIJ2HB8ItTdOCoFb0JDKXLh/RzRbqqIvWQkcb+K3CYO3W4M+WRCXya4yrENKjiVbV7c+SS4/PHd8ALprFZd8kZE2x7c/qaJBkfCqglnuvAsOHHSnNypTqqRu84KSVPkslp/wIYxvCt49E32OeaT5k7qxzNHPpwgub9FeBipLSVYeZkTql5Zaf+kIgkty4PTbEY0RDhptyOGCNWoC4hVxoVuR1n5r79Ynu1MWGkp/Moz7hBf/my7NHjbb4EyvHurgRgyUqDWdqCT1MvY12eWStCFj8hQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EzDyEA8y5tTUxTFX/BZBsAKPXyAy0vKw8vIxJ70NhEU=; b=kv4yY8H0NEXamdGKA6SMx7alte3cfLTPZpzfx2tB96hl07MW+4hTNWFgB4aRt/3OlPJiJY1c4d5OYKRNCrOsoyUAqPef63cCIg121/6lpl18aLpZf8Fwll977brRP5ZsAUyQLsvptK2vQuJ4bLgZIGd4Yivi+pClyrhLSnEwALM= Received: from DBAPR08MB5814.eurprd08.prod.outlook.com (2603:10a6:10:1b1::6) by AS8PR08MB10193.eurprd08.prod.outlook.com (2603:10a6:20b:63e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.22; Thu, 20 Apr 2023 16:56:37 +0000 Received: from DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::621c:838a:cb11:19b7]) by DBAPR08MB5814.eurprd08.prod.outlook.com ([fe80::621c:838a:cb11:19b7%7]) with mapi id 15.20.6319.022; Thu, 20 Apr 2023 16:56:37 +0000 From: Honnappa Nagarahalli To: Yunjian Wang , "dev@dpdk.org" CC: "konstantin.v.ananyev@yandex.ru" , "luyicai@huawei.com" , "stable@dpdk.org" , nd , nd Subject: RE: [dpdk-dev] [PATCH v2] ring: fix use after free in ring release Thread-Topic: [dpdk-dev] [PATCH v2] ring: fix use after free in ring release Thread-Index: AQHZc1OMRL7eOo8QCkK2B+7jhfTaTK80aqAg Date: Thu, 20 Apr 2023 16:56:37 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: B78A6699AF8BDB44AE861F4CE2541CCB.0 x-checkrecipientchecked: true Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: DBAPR08MB5814:EE_|AS8PR08MB10193:EE_|AM7EUR03FT036:EE_|AS8PR08MB7308:EE_ X-MS-Office365-Filtering-Correlation-Id: c568fda9-a3a3-4f66-0391-08db41c039a2 x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: aizvbo1LFIS8i76HxtlmZJco85gVn+u/MfnT0X8abVRUik6VT4sMkolKCobyHbTvnnE0MYdpVqv3t70A0LLMet6s4SS1aQAzMHpNkR2s97pq88U27xjZ+qqYg7H4D5OvHgDujR6rlc+i8Nb0+WZrIRkivD8JovedZuyxiQLZaTFaGdvmqVEDJMyV/nJ1xUOtBvyQBBWg8tSqR2qOmHvXuAVVwhE8s+aDBqIcVrIRa+So8XLEnyNTfSdrwAt1YQQtM7sWcNPs/PecTXhtrqmB6NzMh9MlUv7Dcq/X5EWtxN2OUI/LlUdwJVclfN33B+weBu4ejMpEZEmRJj6cXQsTOP7AAq05M2TnJwnGRaVlx75uXaHfV60aJrjYKKPpc7QgAe7awRIbOxyT98sjjwyqrP1J0Upa1OsgwaLdJnTPSzWSwod9dCi4wZwvvTpiDJd8C+GuXY66rVw+R+/mdnnpa5M0bAqWHFBzmsD/RCiSwA0cI8YmUgqqsNoVt9Odz0ivxOb8p2ugFDKbgE4UqUfvtWwoCE7xylP7QxASW6yJufIpfmmfEVMX3IZK2Oybgx7LkSv+nL26uRgM/NnClleVHcR+9wBgHBYqOMLegMJ2XcPh6qB4YtfcIGVgbDsZYxVhXj8U/nQDtoTd49toCbYBfMqBowglz0xI4Ya8TDsJSpACpcqpw+s6G3qgXlKzJgkpMBRnzMA+2ZMYhI5iKCfSzw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBAPR08MB5814.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(366004)(39860400002)(396003)(136003)(346002)(451199021)(52536014)(478600001)(71200400001)(186003)(6506007)(53546011)(9686003)(26005)(7696005)(83380400001)(38100700002)(122000001)(76116006)(86362001)(4326008)(54906003)(38070700005)(110136005)(41300700001)(8676002)(55016003)(8936002)(66946007)(316002)(66556008)(66476007)(64756008)(66446008)(33656002)(2906002)(5660300002)(23180200003); DIR:OUT; SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10193 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3134a590-69a8-471a-9ecd-08db41c0349e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GDuBgFZDtABfEmh5H30nynqrhYIKee96HNfGDrrSR6ZCpyxKu2FS7UxqJ/ssaO0lRDi4paTdzqmt81wHvDOY3QIjwXARdIvbv608pCthYSnWGheJiaHROec65Kdd8R0tkW75pxlZaDSBKAVGuwnOCd/T7ep/NLKWj+YQ/Icj8IRp708gdHnlGzZYyMVGMZckmdd9ts69e1L1ER0TS2JEWSEabnsivll2ecbKyhGej6bp7tr3D906aSsVftd/2eaxNtf9D2UJUo5s6ggBG1+lOWq3DV9VCKZ2L9ErI5O/FcXgFVakaf/80aHhmi0qF1cmGxR5q7dqYYISE/rNffVrGAN7B3p6a+5TlQb9v0EhQGa7BpZeCWTCQnHxlgTC/rTBavPQtjbHEfjQj32O8z+MVIG2appDjI3OGLrpifb3xQbjEh7ujjEaOpSy8c5HzSfy4SI6fH8WHKOcqcdD5uOfuxfao/abj+EfVknySBY/cAmWpiAbcj+u1Fi+6M5JTnno9msr6+wjRj+e8z/qpJMYf3WZvL0i8rCWXnPGvvevhX4mvTz5pHf8rgspy5M0ZI9Y8hbfX9iBJt9otKf3CHA8VZUIGwLqnlqgwYa508Wnlmwf2Ubg20dkwLaPiHCVLa0LqLo53edACxBwDU9UAJcehjWMusQ6bSsB3f6WHfvyqRFrw7QCCUPZSK3zV/6IZzjtriaPrY9mtZY6DigSPQbM4tfR0BF+HxBM+6mKAOrEzUY= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(39860400002)(136003)(396003)(376002)(451199021)(40470700004)(36840700001)(46966006)(336012)(36860700001)(83380400001)(47076005)(186003)(82310400005)(7696005)(450100002)(478600001)(54906003)(110136005)(70206006)(70586007)(8676002)(5660300002)(52536014)(8936002)(41300700001)(81166007)(82740400003)(4326008)(356005)(316002)(55016003)(40460700003)(40480700001)(9686003)(53546011)(6506007)(2906002)(26005)(33656002)(86362001)(23180200003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2023 16:56:45.8721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c568fda9-a3a3-4f66-0391-08db41c039a2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7308 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 > -----Original Message----- > From: Yunjian Wang > Sent: Thursday, April 20, 2023 1:44 AM > To: dev@dpdk.org > Cc: Honnappa Nagarahalli ; > konstantin.v.ananyev@yandex.ru; luyicai@huawei.com; Yunjian Wang > ; stable@dpdk.org > Subject: [dpdk-dev] [PATCH v2] ring: fix use after free in ring release >=20 > After the memzone is freed, it is not removed from the 'rte_ring_tailq'. > If rte_ring_lookup is called at this time, it will cause a use-after-free= problem. > This change prevents that from happening. >=20 > Fixes: 4e32101f9b01 ("ring: support freeing") > Cc: stable@dpdk.org >=20 > Suggested-by: Honnappa Nagarahalli This is incorrect, this is not a suggestion from me. Please remove this. > Signed-off-by: Yunjian Wang Other than the above, the patch looks fine. Reviewed-by: Honnappa Nagarahalli > --- > v2: update code suggested by Honnappa Nagarahalli > --- > lib/ring/rte_ring.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) >=20 > diff --git a/lib/ring/rte_ring.c b/lib/ring/rte_ring.c index > 8ed455043d..2755323b8a 100644 > --- a/lib/ring/rte_ring.c > +++ b/lib/ring/rte_ring.c > @@ -333,11 +333,6 @@ rte_ring_free(struct rte_ring *r) > return; > } >=20 > - if (rte_memzone_free(r->memzone) !=3D 0) { > - RTE_LOG(ERR, RING, "Cannot free memory\n"); > - return; > - } > - > ring_list =3D RTE_TAILQ_CAST(rte_ring_tailq.head, rte_ring_list); > rte_mcfg_tailq_write_lock(); >=20 > @@ -354,6 +349,9 @@ rte_ring_free(struct rte_ring *r) >=20 > TAILQ_REMOVE(ring_list, te, next); >=20 > + if (rte_memzone_free(r->memzone) !=3D 0) > + RTE_LOG(ERR, RING, "Cannot free memory\n"); > + > rte_mcfg_tailq_write_unlock(); >=20 > rte_free(te); > -- > 2.33.0