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 BF66845F48; Thu, 26 Dec 2024 09:10:43 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8CC8D402AF; Thu, 26 Dec 2024 09:10:43 +0100 (CET) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2081.outbound.protection.outlook.com [40.107.247.81]) by mails.dpdk.org (Postfix) with ESMTP id 902934029D; Thu, 26 Dec 2024 09:10:41 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FfVuPXYzz++G2HdAZuiO1s1TmKt0uGbWFjPxh902Pb+LjnSTm/B/PlEDMoxTnk+MecrOwVP8adegHtCfwIhbzgOmoMum5MXfffZGBewq1J5gOVsX4LHydlQFBJXX/wRaJQHG7zyjI/rU+R8V/mnqj3QW+mFakIdP+8xLg/3nwaIb3k/2CPAR+nEDEjebP08i0vVvRLMdrdLnW3nSShM5UoUTV9NGH91M3jK57laB8njujV/FdTac15j9CNCGnyq/bXdfb+TxMqmTd0qZTspsEJOPZvjMndVVm0unWZr/cgHjNg+rE/0WPGJqFEo6dI4hIGwG4+7ef9uOJc2DAivFiQ== 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=h7uVH4CREki089cg+HN76ALEHMlVj6BegmuC9AZJg4g=; b=ls7QCtsHcqdcl2tlnr3GWIyA67emjqsyP9JTLoL0IpOqn35iW7k9nzgHVdgGcj4kotF+7QkgnMOOFd4rAxPiuKeXHkIgrOscb8MmrKBdizMqQi1Gzc/oRo3C5CsVQZJwX1eeJHLbxR3GaH6laMFmSMn11ElAqf9OfiHZ9o5DGGiNIMCLSctidGtsctVzz/siq5Bbk7juBREeSgBmRTfpkV8H1RdqyABMfJyJQyq9IxyFnOe1dCtqDfs5Z/GEZyivQ/UTnV3QdbFnInYopAHmMLy5rg0t6rLH/gTMlfI8AP1eljrqmHS2NKbfMudtufw3N6vOkcyVE9W9kGbxYKZEyQ== 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=h7uVH4CREki089cg+HN76ALEHMlVj6BegmuC9AZJg4g=; b=m47HaQ6gsX0P1rTW6NxiRWOYwgFgFkH++3R3hvA9dMmBWSplpo9RPLEeo9pP4OsDDwZGlPMUaX1I54Q6Uf73HENaZ0PJQNo2G1dfc6EXquM3FmKlj5NLIna07z49GGNEJuqHWybz807bwHqVXpKUZIUm895UzdxQ0Z0TAGc7veFjVbqOUfNU1V1Y2h2wnEQcjnJkiXBltQzv01+Xe0yxMXggDiesXdZmkLpyjDo3jytYuB8+0gBgMFzil5wvc+EOpEUBtUG5pk9EyXnYXk5UHMgyuKQqORpY+HB/RHMApus1MZko9ITtdoeKXTvUqnZ2jzhzgeAJnlEyUJFBYN2JGA== 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 AS1PR07MB8735.eurprd07.prod.outlook.com (2603:10a6:20b:47a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.15; Thu, 26 Dec 2024 08:10:36 +0000 Received: from VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21]) by VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21%7]) with mapi id 15.20.8293.000; Thu, 26 Dec 2024 08:10:36 +0000 From: Yang Ming To: Anatoly Burakov Cc: dev@dpdk.org, Yang Ming , stable@dpdk.org Subject: [PATCH] Fix unused memseg length for memory issue Date: Thu, 26 Dec 2024 16:10:20 +0800 Message-Id: <20241226081020.3479-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: SG2PR02CA0044.apcprd02.prod.outlook.com (2603:1096:3:18::32) To VI1PR07MB9898.eurprd07.prod.outlook.com (2603:10a6:800:119::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR07MB9898:EE_|AS1PR07MB8735:EE_ X-MS-Office365-Filtering-Correlation-Id: 42c4ee7e-71b6-4334-a945-08dd2584c6cb 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?bUliNEVUTnBoWVd4RVlZTFVSdkZ5UGFsMWQxMzhTd1FHN0dYRXM3TGtkdEJx?= =?utf-8?B?ODNRTFRRNmFkQ1U3dmwzTWtrUk5RalZReTk1MjJYQ0xnTWJQbTgxNUgrWVBI?= =?utf-8?B?OEpzajRWOGtIRnNET2lpY29TZ3BnY2twWmdmMVJTbGJPSUhUalUyRWI3QVhB?= =?utf-8?B?N1FOT0J6TXBhUjhQRGVFWVd2cmZJTVpvd0t6RG5Ya3VPUHQyUnI3TDNwNTQv?= =?utf-8?B?R1dFckNZU3p3UFhQNGo4K1Byb1NZZnM1OFZYTmhBK2NoRFJPTVBFSlQzWTN2?= =?utf-8?B?YVVMOXA0ZldCL0JBbjc5SGQ1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5QjJrZXJBd0xncjFIU2R5dG5aNlMzSVJyV3VRV1l3bWxTenVleVM2bkU1?= =?utf-8?B?R0tTYUVXcWdGNmVOL2lIRWJXcE1IekUwb1YzTk9TOGV4SXdGbjFSazlJb1hT?= =?utf-8?B?aEFhWFdoYU1vQ1RxS2pKbE9rREVFN3ZDWGplMERMdmFHbTA3NDIvVGdVSmZK?= =?utf-8?B?OHFkSHlnbFBLcllrT0NzMmtSb0V5NllCTHMzNVJnOVpBM0gzbmpvdlBaTFJi?= =?utf-8?B?L2dMaU10dmZUWDhyUTJ0bnhLRDhsejhzbCs1Z1lwTHUxanQwdzczQmZCQXJF?= =?utf-8?B?aEJWbzd4Z041Qm5WMExiT3dtNXhSWEVJa2lCVGNCdWVRNSt3Q3NuTmhYVStC?= =?utf-8?B?eUFlMzltWEptaGExSnNBbElOSlZWZFV0UEZpRjRFSXYyOTdrOU5TTTcrRXpN?= =?utf-8?B?NzZWZDA1UmMzVnBTOVJ2bkVMOFVENHVJeHZkL3FLVEsxcWg1Wjl6M2dWaXMy?= =?utf-8?B?MXN0NHNzT2EvZm55eUkvNm5yR1dZUitQZEd0Wk11aVI1OFp6Tzc4RXROVFJF?= =?utf-8?B?R0gxZFl4c1lqMVhoUTNWbmR2WGx5eFBtS01GTkFnNUs4cml1MDFDQldaSTBW?= =?utf-8?B?SGR4SmJURkNRQkxHS0s5eWZaV0xLQ3FJMVlXWVI4aW1sR2xvM05DWUQ2L2Nv?= =?utf-8?Q?ztiVgHhYn4yQL?= 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?dHZIbWZodDB5OFdVZ1FreXY2dmNZN3R4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?B?bUdvZnBSbGZKb1k4LzlBYVRLZTJlRG96WWJtNmpodGd3V2JYRXowOFJIWUxG?= =?utf-8?B?RmpLY1Q0dHFvM3hFcWtwQVZ3U0U5WTVvQ1hYN2VjVjNPSGNTQkQydWlmZGdJ?= =?utf-8?B?R0tmZjNhS004dlZ6UktLV1BJSng1ZlRlSVUzRUY5UFRWSVlRUURCbmZOZldL?= =?utf-8?B?VU9GUldCUDA0RzNEbS9tdWIrSTF0YlFVNm9oUWJhVkpiUkpkRDZDbXZpcno0?= =?utf-8?B?Q1AzL0JwZ3NRM2JnSUFFTmcvdXJZODNvZjRwaU9ZZ3NUYWlHV010cFVkWmtz?= =?utf-8?B?YWJnRkdDbVVZSmpZditSejhlaW9mSy9BeWNHejUyUWp2b1pnc3JPcWl2WXBY?= =?utf-8?B?alE9PQ==?= X-OriginatorOrg: nokia-sbell.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42c4ee7e-71b6-4334-a945-08dd2584c6cb X-MS-Exchange-CrossTenant-AuthSource: VI1PR07MB9898.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Dec 2024 08:10:36.0254 (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: cHgNMuZ32fUHN98r1o44qTfslF8/PpCBh/aDASzeEC20EZ+YRBC8LmpstQJx71eKxQAJ5ibHm2q7U1BqVUxYbBzsZanvuNhixYQExCbLNls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR07MB8735 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, it does not reset their length to 0. As a result, mlx5_mem_is_rte may incorrectly identify OS memory as DPDK 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 DPDK memory. Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") Cc: anatoly.burakov@intel.com Cc: stable@dpdk.org Signed-off-by: Yang Ming --- 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