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 D0B0C4624E for ; Mon, 17 Feb 2025 18:06:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC82F402AB; Mon, 17 Feb 2025 18:06:08 +0100 (CET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id 3E533400D6 for ; Mon, 17 Feb 2025 18:06:07 +0100 (CET) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-43690d4605dso28662135e9.0 for ; Mon, 17 Feb 2025 09:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739811967; x=1740416767; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J+9/J5fZvR3WpXCsrA7la3uWPg5GWX46w5+mdoilTDQ=; b=If+ElIKwmfCHE5a8CGOeZb1eKKGcuXZGpgvtHNY8iEsDwQ58bp9prpXffJlloax7ap hjgisoj3oZne+OH3S2lIt7Yibh+YfEi7mp3cEHUpU1PRVesHtsbYjj+WN3rdmCO7Q+2Z Ma1TZ6i/a3drDfiT69jCdisLT8AkQcGgmriNr/E8Dq6HfmDie5BLqM8bLo+4pJkAZUIm UdIXKIaHK3dhLABIF8ulJymP26zLQmqtbdIciUMAvtJ9kcnYqr7yo+TzqggIEKsiJIm7 6bIVbe94sRMqkNMh43hys3ZXn9n96swpbc9DkeR6lLNf44m/ulpqOFO3essugIBV8+3e kbdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739811967; x=1740416767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J+9/J5fZvR3WpXCsrA7la3uWPg5GWX46w5+mdoilTDQ=; b=H0qOGQmbrl3h17kON9r9GejxdoDUHv368Uq/H5v6DDdwG2pYwBmE4jwbl/T2wU7aEh cPAW4vhNJWz2PspaAbF3AzPO1SXVQI8o8STWXoMFo7IeDOEYRafiiOTniZOU5GHnaSJ7 AT2WKwxF+bSHs/NPEbJLRkzlcTKlEtmRdKSLyE5wiZsFOqgtuFT7jK23nYP2rWokCKEv VVr5VHMqtyQ8dI/9b1hxCHYZ5e1hz+m+SUnKw4xuoUiNazVxjFEF1d3BmfLN8e6Zs5Av vNYq4Gwb7Lmmp2AQOhJbevUauT3mxesc205AhWivw65pDynwc5QYC/PA1IV4O0bMucqQ c38A== X-Forwarded-Encrypted: i=1; AJvYcCWL8zx/h4W7r29zX2fvoP8kCHS6LJca9osIC48nfHsxmmhf/oeHVYmHLirqaVkqMTe2kT/huo0=@dpdk.org X-Gm-Message-State: AOJu0YwbKtJbpV96MuH4ocD78jTyjEu7fXCiIs8E9rI7h7kFDucKxefH keHJWLJmT1lov3THbqGYvtrbTkODf5/oS5tTuPeGG7wYoX/TFTCklr3++PrseBONYw== X-Gm-Gg: ASbGncs+tOmVq3Np0Mv+7E54wCaZ65gG4YbWfz3BLAnaEyg8mHFFZMXOMYNVzfsb/A9 wOr6MWcx3ZMV1GLs1UeMdg936EB7k1vOKFHnk8qe3m4q+BpwnUFmRl10FgXsl/WNKmjlOWO/qmW IGboFYJm7VtJKDCpE/NOPkYYLeNdzbjUVD/pFqI1Xtp4rrn/l8PSm8Vvn/NozX7mn0JwU0+H61a oQhgSix6bXb6/rlIGk9aLBBIMvT2mLsvQGN7403xUCnyP+DDHgg9DbebYEkq+4mUfQLXTHIl8fh lccRiJo+D9q7yrh/dmm1Pg== X-Google-Smtp-Source: AGHT+IGW2gfEG0JIcXUnyzrDcWD5ZBWLq7fJNr9M0AK2KE3xNXVKXcE/BqKLai9sT/Snz7/kulNrpg== X-Received: by 2002:a05:600c:470a:b0:434:f5c0:328d with SMTP id 5b1f17b1804b1-4396e752a98mr94180575e9.23.1739811966561; Mon, 17 Feb 2025 09:06:06 -0800 (PST) Received: from localhost ([2a01:4b00:d036:ae00:f83c:95e7:29fd:a997]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-38f258ccdccsm12794358f8f.24.2025.02.17.09.06.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2025 09:06:05 -0800 (PST) From: luca.boccassi@gmail.com To: Yang Ming Cc: Dmitry Kozlyuk , dpdk stable Subject: patch 'eal/linux: fix memseg length in legacy mem init' has been queued to stable release 22.11.8 Date: Mon, 17 Feb 2025 17:03:55 +0000 Message-ID: <20250217170456.1068278-22-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250217170456.1068278-1-luca.boccassi@gmail.com> References: <20250217170456.1068278-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Hi, FYI, your patch has been queued to stable release 22.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/19/25. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/8d10eae3cd0ec8c0970339a8ae91eac7487f549a Thanks. Luca Boccassi --- >From 8d10eae3cd0ec8c0970339a8ae91eac7487f549a Mon Sep 17 00:00:00 2001 From: Yang Ming Date: Thu, 2 Jan 2025 16:58:38 +0800 Subject: [PATCH] eal/linux: fix memseg length in legacy mem init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ upstream commit b974cbbbef6e1036e7ed7d19fefb7ef8cda0e4a1 ] 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") Signed-off-by: Yang Ming Acked-by: Dmitry Kozlyuk --- .mailmap | 1 + lib/eal/linux/eal_memory.c | 1 + 2 files changed, 2 insertions(+) diff --git a/.mailmap b/.mailmap index 9b6f5f770d..fdcfe1c30a 100644 --- a/.mailmap +++ b/.mailmap @@ -1559,6 +1559,7 @@ Yahui Cao Yajun Wu Yangchao Zhou Yanglong Wu +Yang Ming Yang Zhang Yanjie Xu Yan Xia diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 9b6f08fba8..077f77d406 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.47.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2025-02-17 16:13:17.653512050 +0000 +++ 0022-eal-linux-fix-memseg-length-in-legacy-mem-init.patch 2025-02-17 16:13:16.806441593 +0000 @@ -1 +1 @@ -From b974cbbbef6e1036e7ed7d19fefb7ef8cda0e4a1 Mon Sep 17 00:00:00 2001 +From 8d10eae3cd0ec8c0970339a8ae91eac7487f549a Mon Sep 17 00:00:00 2001 @@ -8,0 +9,2 @@ +[ upstream commit b974cbbbef6e1036e7ed7d19fefb7ef8cda0e4a1 ] + @@ -34 +35,0 @@ -Cc: stable@dpdk.org @@ -44 +45 @@ -index 9209a716e0..19bbdbc0c8 100644 +index 9b6f5f770d..fdcfe1c30a 100644 @@ -47 +48 @@ -@@ -1722,6 +1722,7 @@ Yahui Cao +@@ -1559,6 +1559,7 @@ Yahui Cao @@ -56 +57 @@ -index 45879ca743..9dda60c0e1 100644 +index 9b6f08fba8..077f77d406 100644