[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231031003810.4532-2-gregory.price@memverge.com>
Date: Mon, 30 Oct 2023 20:38:07 -0400
From: Gregory Price <gourry.memverge@...il.com>
To: linux-kernel@...r.kernel.org
Cc: linux-cxl@...r.kernel.org, linux-mm@...ck.org,
ying.huang@...el.com, akpm@...ux-foundation.org,
aneesh.kumar@...ux.ibm.com, weixugc@...gle.com, apopple@...dia.com,
hannes@...xchg.org, tim.c.chen@...el.com, dave.hansen@...el.com,
mhocko@...nel.org, shy828301@...il.com, gregkh@...uxfoundation.org,
rafael@...nel.org, Gregory Price <gregory.price@...verge.com>
Subject: [RFC PATCH v3 1/4] base/node.c: initialize the accessor list before registering
The current code registers the node as available in the node array
before initializing the accessor list. This makes it so that
anything which might access the accessor list as a result of
allocations will cause an undefined memory access.
In one example, an extension to access hmat data during interleave
caused this undefined access as a result of a bulk allocation
that occurs during node initialization but before the accessor
list is initialized.
Initialize the accessor list before making the node generally
available to the global system.
Signed-off-by: Gregory Price <gregory.price@...verge.com>
---
drivers/base/node.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 493d533f8375..4d588f4658c8 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -868,11 +868,15 @@ int __register_one_node(int nid)
{
int error;
int cpu;
+ struct node *node;
- node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);
- if (!node_devices[nid])
+ node = kzalloc(sizeof(struct node), GFP_KERNEL);
+ if (!node)
return -ENOMEM;
+ INIT_LIST_HEAD(&node->access_list);
+ node_devices[nid] = node;
+
error = register_node(node_devices[nid], nid);
/* link cpu under this node */
@@ -881,7 +885,6 @@ int __register_one_node(int nid)
register_cpu_under_node(cpu, nid);
}
- INIT_LIST_HEAD(&node_devices[nid]->access_list);
node_init_caches(nid);
return error;
--
2.39.1
Powered by blists - more mailing lists