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 F00CB45FC4; Thu, 2 Jan 2025 09:59:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C189402D6; Thu, 2 Jan 2025 09:59:03 +0100 (CET) Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2042.outbound.protection.outlook.com [40.107.241.42]) by mails.dpdk.org (Postfix) with ESMTP id CEE1140151; Thu, 2 Jan 2025 09:59:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UKm/tB6MVxfstsyfzDNbpY1imsXWJNUpZlkGZ28Bk77g3+ZZ/isXjqPcHnGnvg6oekWtTFMYfY+ShSK6Nl2Zof9FAZzMUExGDpGRGh2N+aLLjbNe//Jp02pJudn9epAK9yhm9sVbyCCH4bnpbTQ8bA2eFTZd8yyjAFLe3mFfUJISihFiX6/fsS22GqhuCoeZaompPQPKHC8NvYk268Dwd3Sw0wyNdN0NXkM/9PvTGjWrHCIxIbndXttd86w+Qde0+k2GJicojG14/BWnkqYdvNC9cxN0gRsNByQ8/kZ5piYT59frTBF5LZwsWrtyboMR+JWIvaRfktDzxaHnUbO7AA== 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=PBEj+DuyVDIdc4j57V3obldgiVPtiPcxgxVtr9bUNLZOzYJ3P49+oxXpTsq5o6JaTw/6UUfGUm3UihcR1AOMETfIANCEkxmpZa/baMXXVv3dgDawIBIkBf3fFDL6WZ1rF4Q1IlYGxZxmLuEZ76ef5/X07ZusIoZKbmMBYtvdJNrmofHr27oAjVbr0T/SuCfyaDAg0LzzwUfTIF5Hhe5+Dcc0ARamVSwvMLQLO5fPWJ/acHLHU+vE7PU5vUwQVjEnUhoGFyPd7sdUAI1f3c+2pb163ShAf4iqtc3erLNtXB78Flz8IcnR3pN2Zod9cCk3V0cUN1Dd2xNWUmgbIql9lQ== 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=fO+z+RjpE55IY0yjI7p/0VEyN0NjB9Wp465+nPRd1odkhKeazajbuNK6AG+BCbnjI82OaRHxdDUimTZa4mjpaB6qPRKT0pBs9Y+tpFMX+fRCauAdp+I2zbvUZAFBATR/jgk2mHD0V/6rckfznzLfbWFWHPkzB0fiJB4X6suM7b0Tan4G9B4xnnLsNxuVFU+pmpUplYrDJyp9yWmOqI+AnSLWzJ/9PHcFExDNSkIDhgR+nLA90pUfLseINjK5U9AjJijaNSWO3RjvB8PPeVzBX7DgmkLw6DwktRVAoWi42CxGdurKOcQE/pSNEGH+ar7ArLqoyoh7jSRJKVGhTvIbGA== 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 DB8PR07MB6283.eurprd07.prod.outlook.com (2603:10a6:10:140::9) 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 08:58:56 +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 08:58:56 +0000 From: Yang Ming To: dev@dpdk.org Cc: Yang Ming , anatoly.burakov@intel.com, stable@dpdk.org, Dmitry Kozlyuk Subject: [PATCH v2] eal: fix unused memseg length Date: Thu, 2 Jan 2025 16:58:38 +0800 Message-Id: <20250102085838.991-1-ming.1.yang@nokia-sbell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241226081020.3479-1-ming.1.yang@nokia-sbell.com> References: <20241226081020.3479-1-ming.1.yang@nokia-sbell.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2P153CA0033.APCP153.PROD.OUTLOOK.COM (2603:1096:4:190::21) To VI1PR07MB9898.eurprd07.prod.outlook.com (2603:10a6:800:119::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR07MB9898:EE_|DB8PR07MB6283:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e0752d9-d6fb-47c6-3bdc-08dd2b0bb040 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OUhSZnE0KzA2UDJWWm1CbjFYZDNJSkpndXRQcDFlZkEyOCszNGhCRktEVFZV?= =?utf-8?B?NHlncmhHdWp2K0RRTTBwKy9SL3pMTDM3S1VIZ0drdHFTNm9uRTZia3Z4d29h?= =?utf-8?B?bzB2RlZTYUdLanJZbXlVNkwreTNZUUFZUFBCUjl4WHZEd2FwMDAyVjRmWVhX?= =?utf-8?B?anhuQTJ4Z241UEU5UisrczJDS3ZvZ0hZUk5lSU13Z1ZRcnRpS3JQQ28xQm5N?= =?utf-8?B?M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Qy9K?= =?utf-8?B?WmNLYVRXTGNGVlpiR1k2c3ZTaTEraTJtYTVianZZRUZGSmlnR3VaNUE1MWxL?= =?utf-8?B?emxwSzJVOGVaSmNtYTk5MldaTWFxZWs5OFZvT0R2NkxGbkVHRGh1V2JhaUho?= =?utf-8?B?Z2RRdUo0eS9GRElud0x0SXJzd0tubGdmbkpVd3loMUlrVFcxUERHUzRHUytk?= =?utf-8?B?QWhOYUYzVGlrOUNNUnZJNEE2OFJxYWhsdHUvOTZSOHp0TGpDblIwRFQ0MEdM?= =?utf-8?B?TjBXNk5vWHkrRkkwUnF3dlRFNzNEdXc4R3pqSWkyb3NtK3ltR3AzYzdJNVB6?= =?utf-8?B?d3owZExZTmRPcjNSNzhpU2hhMEFJc1F5TzI2UjkrbUIxaGhYT1pFc3NFNnZ0?= =?utf-8?B?V3E5U1c0bGF0L0pRcUVzUGRRWG0vSU9TekZIZHYrdk16WW9uUjVBSHNzbGxD?= =?utf-8?B?YjErQ2M0YzA4Z2ZUUGNxN0lMSXJ0MXUrMTcwek4vUXVQSnVJOUprUlQ1S2Na?= =?utf-8?B?Szh2U0d4a2dXS0xGYmZiaFFJZGNXWG5HZlp1YTlyMXA0a2VVSUh5dFBNd3NN?= =?utf-8?B?dHdjNFhjUXRkMk85UGx3clAvZ1NhdlRLbmFKWGN1eVlEemc3Vi8zYXAxa2o1?= =?utf-8?B?TmxWNS9JMkhYbU8ybWpPZmlVOUxPNE0xTEJIUmc1TFpCa3hlSXllU3daVFR2?= =?utf-8?B?UG9STTdYRjh3UWZpZmhDTXBaZ0xkZ2lURXM4dzRydU8waVFYMzB6Q0ZMNjJO?= =?utf-8?Q?2Ghg0kZhBtUfV?= 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); DIR:OUT; SFP:1101; X-MS-Exch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FEemlmL05m?= =?utf-8?B?d1Fmd0NsdGRoVVI3N2V1Ync5dEo0dWFLZDhzK3VneVBqRkZVVGF0YXlOb3ZR?= =?utf-8?B?WEM1dU1ObjFwRnViTHJUMmFpaXBwK05CTnY1bmZ5cEMxempybHRwRVdPZ0tO?= =?utf-8?B?dUFPSHRpamRZMEo4cFBqdUJFU0RoN1lYbExObW93Ujl6M0pJZlQ4QlZ4U1JO?= =?utf-8?B?dUpBS0NRdFN3cVJmSENLcVN6eHFRRGtMUkMxcmM3Y29CVVY5aHBHRDNhM0pZ?= =?utf-8?B?Ulg2LzFSMzJCRnhMT3crS0RjOS9vMTBEWEppeTJBRWtQM3VQVXlVWVdvSzha?= =?utf-8?B?WlBGR1RZSHdEMmdwSksvSlZQRzhwMDFnM3JGZDU4Vnd6MjVkZGxibUUrdWV5?= =?utf-8?B?UUx4RmR2YjBXNHpmVjZhSFZVOG5Oem8zWXhWbmErVlNDekg3WjRRYTJmNEx2?= =?utf-8?B?bHc9PQ==?= X-OriginatorOrg: nokia-sbell.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e0752d9-d6fb-47c6-3bdc-08dd2b0bb040 X-MS-Exchange-CrossTenant-AuthSource: VI1PR07MB9898.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jan 2025 08:58:56.0871 (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: wEiXauNJZHOZnD+Ls06Fq3R/PBvn1kWBC35SbZva+tlAqI083LZqeSdTfBw0sEtpKat+sI2QjcFJC1nbGYRv3+qUlHLeFCDjgOcgy5SnLgU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR07MB6283 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