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 4DA71460DB; Wed, 22 Jan 2025 04:14:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30879402B2; Wed, 22 Jan 2025 04:14:26 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2084.outbound.protection.outlook.com [40.107.105.84]) by mails.dpdk.org (Postfix) with ESMTP id 52F66402A9; Wed, 22 Jan 2025 04:14:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AIPblx1ym6G5WFPEVH7IDwkj3FcIKO+/ezdaXevsOvPsobkrlmeAXDtVSPoNzxoaP70r3O3WaRC6uIkaKkqnQ5e56r4TchttnAOD1uUZAnO2bYGwUssgyA0r1glc7VAYwYmBvgcyM55aAcaoCgcEe4lJ7Cc2UjplH2kYWXMpj3neb8bxCGS04SLVF4mDmydv/DyD6b1dlOQonVtU2bb8xCI3NJ1WfEEGOvZzFdct3u0mvWdF3QNjv2lXd9+c95t1O2tEaz1feHCFkwH4ObDGqFeMfasgPv6BmquJOZt+2/e6b6dD7HSCTTCeO5IQ2CbmCMjLmsmkqRlimLm277XS4w== 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=PRcknLrvt1T1J8y8OP6cGRrazLwXOiU8tHrTUQCX5ho=; b=AB3+RnQPq3jHGKOi/HFjr2MjnGVYGvKpoHsxUfWDOqEIa3X87pxjSOJvldIULAYUbMChPV/78GT26HNeqGPMmCbeyXISOq4wCIFbyXyZ3Tg9bIHxv87rnx2EJE3ZMu+gJ0ENKhKpOhJd4tc84zJyeeDXrUxhxSL/j5vYRgWfGbt8s534sc7vTnwBHwptxhWfqUfDBBat/y+Jet9XLwPb+V41BVC8BsZiSrxQCT8zEbI9utPfFUewf4ILHSCSKiMK25GmGYyoxjxTcakhmZsvt+MmANszwCWi3p8lAPd+bdEEnptPUiMVbBhScWYeairE7iHLvaOwciZhyDlb2eurDA== 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=PRcknLrvt1T1J8y8OP6cGRrazLwXOiU8tHrTUQCX5ho=; b=EZVsCXiepGUcbtJ/YGV2Rs5wJRH1qzBBiAtGz6Nt7PNxbYXByeLRci9nrPNs7KRUG0UQSSfrUThaXftcKHjit5Bhcg4OHeOT3OcoXJ2HGW4+keCRp/I68eyrGzO8J0J1HM04xOOGla7sCzIXddLPm0vDdzQdLch4Zl9syjujGUBWg9htoXtZOx0Z1xjH0K2uTmwM3tji1Z4vx7q8QUvWxeG5PjE+7RZbqomoHprF7TaRF6KXsqiR4JeM0sodKszvLq38i+5qHrDyOf5/QON2ef/w+3yLmClwi7BnfSs5XSnlx9140ufQWO9Kwz5WCS9rPapTpeZJRu13yLbkgIFILQ== 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 PAXPR07MB9641.eurprd07.prod.outlook.com (2603:10a6:102:248::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Wed, 22 Jan 2025 03:14:21 +0000 Received: from VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21]) by VI1PR07MB9898.eurprd07.prod.outlook.com ([fe80::1928:4afb:4eee:1f21%6]) with mapi id 15.20.8356.020; Wed, 22 Jan 2025 03:14:21 +0000 Message-ID: Date: Wed, 22 Jan 2025 11:14:15 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] eal: fix unused memseg length To: dev@dpdk.org, Thomas Monjalon Cc: anatoly.burakov@intel.com, stable@dpdk.org, Dmitry Kozlyuk References: <20241226081020.3479-1-ming.1.yang@nokia-sbell.com> <20250102085838.991-1-ming.1.yang@nokia-sbell.com> Content-Language: en-US From: Yang Ming In-Reply-To: <20250102085838.991-1-ming.1.yang@nokia-sbell.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SGBP274CA0013.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b0::25) To VI1PR07MB9898.eurprd07.prod.outlook.com (2603:10a6:800:119::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR07MB9898:EE_|PAXPR07MB9641:EE_ X-MS-Office365-Filtering-Correlation-Id: 229d6299-0a1c-493e-ac19-08dd3a92dd6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NTByS1VJQ0JWTGxIVk4yeW1xRnozR2VKczAzQkxZQVZUU2VpVGx6Ty9XQktG?= =?utf-8?B?N2llcHppOVpWMUFrMS9BSE43UDJwZXkzbldrOGFIZFkrRU4zSVlkNmhqczky?= =?utf-8?B?V1duOC9ySm40bDNlZkc3RXJXNlhOQm9wcXlURmdrajhBRmJlL1luKzEyWURr?= =?utf-8?B?azU2RXJTdFBjb1BIYXBFODJTRUpnTExNb0YzMU5jaEMvVmFPeTJsYlZFTDY4?= =?utf-8?B?UT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rQXRKZGhJSWpL?= =?utf-8?B?NDVYSDFJNG1hclZZckNjUDR2WEZmUGo4Rk92OGZvcHVIKzR2bDVkWjFnWWJr?= =?utf-8?B?RnpyK2RCZFdPMVVUUVRhRDJJV21zcjhsRFBnRDVIMUZJNXBGSStZWi95TVQy?= =?utf-8?B?R1hkRmFXOXVFUUh4WnlJQjRpbDVQdllXSERjcGFGUGFwNE5LZWZCU3BiRlJL?= =?utf-8?B?KzVnUXNNbEdzVXg0UE9yM1NOMUZ5MFpPN3ZWemtHMnJ6RHZjTmRGdno2NkZ5?= =?utf-8?B?TmhEVnI2eXMyR0kwWWhBTVoyWFVjMlBqY2o5aHYvUjg5ejdLM0FERDJGQ2Rh?= =?utf-8?B?Nm5VenFsc1JhekMyNE9vWHlaQ0pjdzNmYXlyR2xsdUx6enJBRG5QWFBRVDJx?= =?utf-8?B?RHVscG5KTWpmV1VOaWtWTFhiT3huRzc4YVhiNjBHRGl5R3B5Y1pzSkJPc3kw?= =?utf-8?B?Rm4yOFVlY0F3RjV2K2U2OUxMVFFDRVNEZUtJaGI3NXdEbFlyUmRTYmRjbEJC?= =?utf-8?B?VFBIcnR3dThJR0M5MXo4YUdxRjJHYWwrYmY5SFlyL0tkS0pMczUwR1NGNmls?= =?utf-8?B?RGhPSWQya2s1NnZTOGRlQUN5b3ptNFhFMG9EUndHMm1pZk5iOUtCaDRiTFZN?= =?utf-8?B?elM4QXppRW01U05kKzhJOHBrb2tsZWRXSnB5dFZMWFkzZmdEVjhoWXJBQysz?= =?utf-8?B?c1crZEkxQnRuRW1wMUZEWjNHU0VoTDg2N01mSVI2cHBZMkhKNFhQVFRzb1Fv?= =?utf-8?Q?VEcw2EdUrxygw?= 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)(1800799024)(366016)(376014); DIR:OUT; SFP:1101; X-M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R3?= =?utf-8?B?TmFrRGpJVk8vY0ZXSlZpSXhoaEZTeTU5NzF5THo0QStWRitkc2NtNmdCUkt2?= =?utf-8?B?clpUZmVUQ0ZrVFRLUU9TZUtCRU05QjVjWk83VXV3NWxOa21CZzRDbE9KclJk?= =?utf-8?B?bDNxMTdvMU1RR2lmZG5wSDZvcmd0bWlSMTQ5Y1F4NzBJMFZOVTBrWTFOUkJm?= =?utf-8?B?VTh2VjRsT0pFU29uZ0RNcjh5c0J0QUtiS3dnMXBlR1NTellSWWlpVm9ydlhW?= =?utf-8?B?VVhoNHU1VnQwbGZuOGhJVnlxT2k4VXdaMUViamU1dU1EcDJIV24yT09FcEdj?= =?utf-8?B?RFhBMTB3WVErVGZDdExCd2hqVytnYTh6R3ZqZTZHOW9SY3FTcjlUWlJ6RXY5?= =?utf-8?B?SkFIUmpkUDBJcE0xMTFOMzlnVkxNeVl0eVArRzhDRXZPeUozcDhSRUkxZzFJ?= =?utf-8?B?Umc9PQ==?= X-OriginatorOrg: nokia-sbell.com X-MS-Exchange-CrossTenant-Network-Message-Id: 229d6299-0a1c-493e-ac19-08dd3a92dd6d X-MS-Exchange-CrossTenant-AuthSource: VI1PR07MB9898.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 03:14:21.4086 (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: A5wV9hm83PDInnjW4fsVgYjU8h/TkEAbGrpy9uJEJhZc104cEN5T4+baqdj+BAcVweIF7quO7uCXQgp3O/jhFITIjT09Mc6U/UoH4ssC+70= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR07MB9641 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 Hi experts, is there any chance to review and accept this patch? On 2025/1/2 16:58, Yang Ming wrote: > 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 */