lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230525115742.124190-1-wangkefeng.wang@huawei.com>
Date:   Thu, 25 May 2023 19:57:42 +0800
From:   Kefeng Wang <wangkefeng.wang@...wei.com>
To:     Mike Rapoport <rppt@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>, <linux-mm@...ck.org>
CC:     <linux-kernel@...r.kernel.org>, <tsahu@...ux.ibm.com>,
        <anshuman.khandual@....com>, <ssawgyw@...il.com>,
        Kefeng Wang <wangkefeng.wang@...wei.com>
Subject: [PATCH v2] memblock: update numa node of memblk reserved type

The numa node of memblk reserved type is always wrong when check
memblock_dump_all() or sysfs file (/sys/kernel/debug/memblock/reserved),
no one use reserved type's node except the two debug interfaces,
but uncorrect value is bad as the above interfaces are visible for
user. Let's fix it according to the numa node information from memblk
memory type by adding a memblock_reserved_update_node(), note, it will
be called twice since memblock_reserve could still be called after
memblock_dump_all(), or the sysfs file read may get some wrong value.

Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
---
v2: 
- update changelog, explain why update reserved node info twice
- move memblock_reserved_update_node() from sysfs read into
  memblock_init_debugfs()

 mm/memblock.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/mm/memblock.c b/mm/memblock.c
index c5c80d9bcea3..50dd12958e60 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1899,6 +1899,28 @@ phys_addr_t __init_memblock memblock_get_current_limit(void)
 	return memblock.current_limit;
 }
 
+static void __init_memblock memblock_reserved_update_node(void)
+{
+	struct memblock_region *rgn;
+	phys_addr_t base, end, size;
+	int ret;
+
+	if (!IS_ENABLED(CONFIG_NUMA))
+		return;
+
+	for_each_mem_region(rgn) {
+		base = rgn->base;
+		size = rgn->size;
+		end = base + size - 1;
+
+		ret = memblock_set_node(base, size, &memblock.reserved,
+					memblock_get_region_node(rgn));
+		if (ret)
+			pr_err("memblock: Failed to update reserved [%pa-%pa] node",
+			       &base, &end);
+	}
+}
+
 static void __init_memblock memblock_dump(struct memblock_type *type)
 {
 	phys_addr_t base, end, size;
@@ -1932,6 +1954,7 @@ static void __init_memblock __memblock_dump_all(void)
 		&memblock.memory.total_size,
 		&memblock.reserved.total_size);
 
+	memblock_reserved_update_node();
 	memblock_dump(&memblock.memory);
 	memblock_dump(&memblock.reserved);
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
@@ -2209,6 +2232,7 @@ static int __init memblock_init_debugfs(void)
 	debugfs_create_file("physmem", 0444, root, &physmem,
 			    &memblock_debug_fops);
 #endif
+	memblock_reserved_update_node();
 
 	return 0;
 }
-- 
2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ