Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes: > On Tue, 30 Nov 2021 14:29:02 +0530 "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> wrote: > >> > What's the thinking here? The node can later be offlined and the >> > kernel takes no action to reset home nodes, so why not permit setting a >> > presently-offline node as the home node? Checking here seems rather >> > arbitrary? >> >> The node online check was needed to avoid accessing >> uninitialised pgdat structure. Such an access can result in >> below crash > > Oh. This is unobvious from reading the code. Which calls for a > comment, no? updated @@ -1497,6 +1498,10 @@ SYSCALL_DEFINE4(set_mempolicy_home_node, unsigned long, start, unsigned long, le if (flags != 0) return -EINVAL; + /* + * Check home_node is online to avoid accessing uninitialized + * NODE_DATA. + */ if (home_node >= MAX_NUMNODES || !node_online(home_node)) return -EINVAL;