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 9606345FC4; Thu, 2 Jan 2025 08:27:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16E434021E; Thu, 2 Jan 2025 08:27:09 +0100 (CET) Received: from PA4PR04CU001.outbound.protection.outlook.com (mail-francecentralazon11013060.outbound.protection.outlook.com [40.107.162.60]) by mails.dpdk.org (Postfix) with ESMTP id 8FE5F40151; Thu, 2 Jan 2025 08:27:07 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jijMIRnEI0hfhYgv4fFDOE3ANZOrZd9k7XDWVB0oVeAZRBpN/BSo/gCQgo2j/z+nLZ7V+wrzQ/jJ55N+319TIFsN03ONtt7q75ozyxmiz24AIBuIT+PBYFJbxlRPpSSTwyoyo9Pw1sNfCKaSETiSjp1gepjDQ2koJLSkjMiD3sZlSZky7b5vBqqccuuaV4EwNyb7233XmvEMDHx1Twj7suJDayTeVamPVSMb2H8twJfBK+pmorzUDnLTbRjEiiXCFpToHzAdHo9QhQx8x8ixEt/kHQlnwlqC8uhVcMiTX8RMqD9xofDMoUoucrFasOAFBD7xebsHrHA3vcbOcnJTsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=kNNekfODdATQJI9HDvAM/Lll8US/CObbUdQCLNb8+8Y=; b=lb6F4EoHlnvzs+CBg/S3hYLNjrTYRnigTMzNWVkq7ybwZwim8OZy03XP07JvNW++RcGsstqNtVF/EjOaf+s8PdV9lCqsVYkIQXfImviEF9zQad3aqeaMJ6m2EOpbdUkaLgFompA+jn2RwISq3XE0kdLi7TZVgYBmRZzYYL1WkWH2r3+/tAgrH+IrG5OS81GK2tGfVHhLGXciCjX9eTVaRZtWUDx3KCAXoWzlThMizFNW+Gbp4r0zuDYWxo7hhTZY2YDDFpM6CFh0NQdYv/fNrIM06tkyic/kHpsphn8aeAMQeIjd/UTqSM6MVHYrR0dgXaH3OvnWSXrfwnX7AxIC9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nokia-sbell.com; dmarc=pass action=none header.from=nokia-sbell.com; dkim=pass header.d=nokia-sbell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia-sbell.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kNNekfODdATQJI9HDvAM/Lll8US/CObbUdQCLNb8+8Y=; b=N33LtxnVY58fpFTAA1YUiz7Pn/aJHxFPw3I8uq5e/TgZP1213YR8Oh3xqQ1pS/iqEFgsa0S4uLQuolUbH7g75rJiceBG9McAz1O22WzB4Kkc2LPzu4VaY1C4GiYQzp+MfdUqJ6xDga25FA4zImRrg8n/tRg6gPyH0lYpPMYRnBe7iZIvkT8gzrE4R7RkLNO8RLqk5iionqHS8M6eBGWfsrVZsc/zSILK6RjMmqXZ9I0+I3QxeahRxIYEqC9mdrPdIpbdvtbCrs1Jl+B2RoyXoFCpEzAoN0ssvv++tD9Jv/gr35mrYSB0J4hinc9GM0UFzgY0MSGTE72hsPeStzkM2w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nokia-sbell.com; Received: from VI1PR07MB9898.eurprd07.prod.outlook.com (2603:10a6:800:119::6) by PA4PR07MB7390.eurprd07.prod.outlook.com (2603:10a6:102:cf::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Thu, 2 Jan 2025 07:27:02 +0000 Received: from VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21]) by VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21%5]) with mapi id 15.20.8314.013; Thu, 2 Jan 2025 07:27:02 +0000 From: Yang Ming To: Anatoly Burakov Cc: dev@dpdk.org, Yang Ming , stable@dpdk.org, Dmitry Kozlyuk Subject: [PATCH v2] eal: fix unused memseg length Date: Thu, 2 Jan 2025 15:26:30 +0800 Message-Id: <20250102072630.894-1-ming.1.yang@nokia-sbell.com> X-Mailer: git-send-email 2.34.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR04CA0018.apcprd04.prod.outlook.com (2603:1096:4:197::9) To VI1PR07MB9898.eurprd07.prod.outlook.com (2603:10a6:800:119::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR07MB9898:EE_|PA4PR07MB7390:EE_ X-MS-Office365-Filtering-Correlation-Id: b95492f9-e81e-4a7c-8879-08dd2afed9cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016|7053199007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dEVnbTFKUm9yb05JalR5US9HRDJsTTRzbDJkS0ZvaWFwbWNZOFAvRU9nVWVt?= =?utf-8?B?dWFkK3BEcGI5NFFpaDkrSy9BcjVZS0NRaUZONTR4S2dkc1VRMWhiTnl1SjhX?= =?utf-8?B?VWQxZHVkYVV2RVhKejFad3gvMWs5NzM5QWIrcDE5eFg0RCtidHZFVXZ1OWVB?= =?utf-8?B?cEw3MVU4ZEFob2Zjd2xtNzViemp6YWJyVFE1b0dqMDRycFcxQi9oRWxmalh1?= =?utf-8?B?cDhubUtYbUJyV0QzNTI2R0lGTk15NVM3Q1l4Y2xoanBVUjZGWDFZRXVTcG5E?= =?utf-8?B?OGluZGxtTzl3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?B?SThNL0E3S09UV3EwdXZVWW5nMTFMOWtKeUc0NmlVc3NCM3RCTG81VXIxQTZ1?= =?utf-8?B?Z1paOElmeEhaVVpwS1JkdmNJcjBBZzVEU0w2MFB3aEFFeE5VYzJBWlpaZDVZ?= =?utf-8?B?WXRjTEdPaEVJK09zUTRlOTFDNmlNNkgvMTFxM2FyTWVobUNqWVVDMSt0eERz?= =?utf-8?B?MUgwdEFucklDcnMwUjdSQVdSN1VpakV6VkxVSnJZZFdmcHl5dmswVzNBQUpJ?= =?utf-8?B?RUpyMHpacnU2MGxIYzhweXJ0SXZlS1RSSDQ3T0UzWFdlOVQ2WW5EMzJTaTZC?= =?utf-8?B?Ny9RZlFrUFZRZGxUTXFxU0JQbFdLYWFjb3ZiNnp4TXhIYVFIcWFoQ2NuaElh?= =?utf-8?B?UVZxeWxvcTVCYVJiTWlQOEJzS2RraWovTFY2V0RPV1JIZUp6NmJ0Vks5MlhJ?= =?utf-8?B?RVlHdlo2WkdDYlRLcFpoUFNub3hMV1ZkNW9ZOGNUdU9oaW81UGhQYmN3eU96?= =?utf-8?B?U1RlSlpjZXNnVGx4V0R6ZFlUQ3RoYU04SFhhbkpnRitkTUFnVXdrQzJIcERW?= =?utf-8?B?K0x1eFZrd3pFTmpINDV5MHhWam1UU0g4ME9GVVI1dytXMnR1d0t5TmZ0TnJv?= =?utf-8?B?cnNyeWpFdFRpNlRtTVhyZ0dhQUkvMUJidVdUMVphY2dKRUx2Y0w4S3ZMWTBC?= =?utf-8?Q?i2gMPBsJ5gD/+?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR07MB9898.eurprd07.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(7053199007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VW0xeE9JaFZZRF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utf-8?B?RWZSSml1cVNmZndrQjg1a285WkYxRXZBMml0Mll5eG1NM1U3WUorNldQeGd4?= =?utf-8?B?Si9iUHdpUnFjRks1VVZXbkNOUzlGYWhKTU44dHBmRUd5eENDRGxRYlUvTk5v?= =?utf-8?B?VXlhWWlQSUVGM2plRWR4RzdOQWJoMUlwRDV5NGVWUlM3WVlSVkJxSjVPZGhN?= =?utf-8?B?Mk9jb3o1aDdzUUcvUDdxQzNYK3F2cGpnY2o5ZVlRZWdnY1dNaXFvM1NwOU85?= =?utf-8?B?d2xkN3JYRUJVcVFmb29zRllQenBKbnlxdnVvL1FNdFA1VDFiOGhPWkZmZGt1?= =?utf-8?B?emdhTFhoSlR0T3Npc3pBdktjV1pwZ3ArNS96N0M0QWpSU1ZDV0c1QWJJdjQ4?= =?utf-8?B?Z2c9PQ==?= X-OriginatorOrg: nokia-sbell.com X-MS-Exchange-CrossTenant-Network-Message-Id: b95492f9-e81e-4a7c-8879-08dd2afed9cb X-MS-Exchange-CrossTenant-AuthSource: VI1PR07MB9898.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 07:27:02.3015 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vCNlGN1+JE/+0WCZ+bIgP1OhZDyruHhf0loGqxC7CbiaV/6ZXlaBrJ4qlEf7FccUldF79U3bInWam3PiX8GmaAf6uFpDlOBfBtrvDyc3DG0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR07MB7390 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 Fix the issue where OS memory is mistakenly freed with rte_free by setting the length (len) of unused memseg to 0. When `eal_legacy_hugepage_init()` releases the VA space for unused memseg lists(MSLs), it does not reset MSLs' length to 0. As a result, `mlx5_mem_is_rte()` may incorrectly identify OS memory as rte memory. This can lead to `mlx_free()` calling `rte_free()` on OS memory, causing an "EAL: Error: Invalid memory" log and failing to free the OS memory. This issue is occasional and occurs when the DPDK program’s memory map places the heap address range between 0 and len(32G). In such cases, malloc may return an address less than len, causing `mlx5_mem_is_rte()` to incorrectly treat it as rte memory. Also, consider how the MSL with `base_va == NULL` ends up in `mlx5_mem_is_rte()`. It comes from `rte_mem_virt2memseg_list()` which iterates MSLs and checks that an address belongs to [`base_va`; `base_va+len`) without checking whether `base_va == NULL` i.e. that the MSL is inactive. So this patch also corrects `rte_mem_virt2memseg_list()` behavior. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Yang Ming Acked-by: Dmitry Kozlyuk --- lib/eal/linux/eal_memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 45879ca743..9dda60c0e1 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -1472,6 +1472,7 @@ eal_legacy_hugepage_init(void) mem_sz = msl->len; munmap(msl->base_va, mem_sz); msl->base_va = NULL; + msl->len = 0; msl->heap = 0; /* destroy backing fbarray */ -- 2.34.1