diff --git a/0004-backport-Fix-out-of-memory-handling-buffer-growing-for-nodes-probing.patch b/0004-backport-Fix-out-of-memory-handling-buffer-growing-for-nodes-probing.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b84239521f2386cb06e7a74360b5a37b167b04d --- /dev/null +++ b/0004-backport-Fix-out-of-memory-handling-buffer-growing-for-nodes-probing.patch @@ -0,0 +1,51 @@ +From a4cd34c58144f7f39cf4f2cea690774b1ac65292 Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Mon, 30 Jun 2025 15:38:54 -0700 +Subject: [PATCH] Fix out of memory handling buffer growing for nodes probing + +When the buffer was too small in the first try, but the second +allocation fails free the original buffer before returning. + +Handle the case when the fallback buffer is used, also only in +out of memory situations. + +Signed-off-by: Andi Kleen +--- + libnuma.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/libnuma.c b/libnuma.c +index ef93558..329cff5 100644 +--- a/libnuma.c ++++ b/libnuma.c +@@ -423,13 +423,16 @@ set_nodemask_size(void) + done: + if (nodemask_sz == 0) {/* fall back on error */ + int pol; +- unsigned long *mask = NULL; ++ unsigned long *mask = NULL, *origmask; + nodemask_sz = 16; + do { + nodemask_sz <<= 1; ++ origmask = mask; + mask = realloc(mask, nodemask_sz / 8); +- if (!mask) ++ if (!mask) { ++ free(origmask); + return; ++ } + } while (get_mempolicy(&pol, mask, nodemask_sz + 1, 0, 0) < 0 && errno == EINVAL && + nodemask_sz < 4096*8); + free(mask); +@@ -1421,7 +1424,7 @@ numa_node_to_cpus_v1(int node, unsigned long *buffer, int bufferlen) + } + + free(line); +- memcpy(buffer, mask, buflen_needed); ++ memmove(buffer, mask, buflen_needed); + + /* slightly racy, see above */ + if (node_cpu_mask_v1[node]) { +-- +2.33.0 + diff --git a/numactl.spec b/numactl.spec index f1f1824de311bcb6cd100f6330bb581f861819f8..6f3c3ea407b47e46e0929a852b93d4caa6c8004a 100644 --- a/numactl.spec +++ b/numactl.spec @@ -1,6 +1,6 @@ Name: numactl Version: 2.0.17 -Release: 4 +Release: 5 Summary: Library for tuning for Non Uniform Memory Access machines License: GPLv2 URL: https://github.com/numactl/numactl @@ -10,6 +10,7 @@ BuildRequires: libtool automake autoconf Patch0001: 0001-libnuma-Fix-unexpected-output.patch Patch0002: 0002-libnuma-Fix-incorrect-print-and-exit-of-numa_preferr.patch Patch0003: 0003-fix-the-using-of-the-uninitialized-value.patch +Patch0004: 0004-backport-Fix-out-of-memory-handling-buffer-growing-for-nodes-probing.patch %description Simple NUMA policy support. It consists of a numactl program to run other @@ -78,6 +79,9 @@ LD_LIBRARY_PATH=$(pwd)/.libs make check %{_mandir}/man3/*.3* %changelog +* Tue Oct 21 2025 xuchenchen - 2.0.17-5 +- libnuma: Fix out of memory handling buffer growing for nodes probing + * Tue Jul 01 2025 wangxiao - 2.0.17-4 - delete macros in changelog