diff options
author | Tang Chen <[email protected]> | 2014-02-06 12:04:27 -0800 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2014-02-06 13:48:51 -0800 |
commit | 7bc35fdde6724549a0239b71e08b9f33d8bf2bfb (patch) | |
tree | 27bef5374ec3d9f888feba0b10381dba0481bc21 /tools/perf/scripts/python/Perf-Trace-Util/Context.c | |
parent | 017c217a26e9bf6948482f751b30d0507e30a7d0 (diff) |
arch/x86/mm/numa.c: fix array index overflow when synchronizing nid to memblock.reserved.
The following path will cause array out of bound.
memblock_add_region() will always set nid in memblock.reserved to
MAX_NUMNODES. In numa_register_memblks(), after we set all nid to
correct valus in memblock.reserved, we called setup_node_data(), and
used memblock_alloc_nid() to allocate memory, with nid set to
MAX_NUMNODES.
The nodemask_t type can be seen as a bit array. And the index is 0 ~
MAX_NUMNODES-1.
After that, when we call node_set() in numa_clear_kernel_node_hotplug(),
the nodemask_t got an index of value MAX_NUMNODES, which is out of [0 ~
MAX_NUMNODES-1].
See below:
numa_init()
|---> numa_register_memblks()
| |---> memblock_set_node(memory) set correct nid in memblock.memory
| |---> memblock_set_node(reserved) set correct nid in memblock.reserved
| |......
| |---> setup_node_data()
| |---> memblock_alloc_nid() here, nid is set to MAX_NUMNODES (1024)
|......
|---> numa_clear_kernel_node_hotplug()
|---> node_set() here, we have an index 1024, and overflowed
This patch moves nid setting to numa_clear_kernel_node_hotplug() to fix
this problem.
Reported-by: Dave Jones <[email protected]>
Signed-off-by: Tang Chen <[email protected]>
Tested-by: Gu Zheng <[email protected]>
Reported-by: Dave Jones <[email protected]>
Cc: David Rientjes <[email protected]>
Tested-by: Dave Jones <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/Perf-Trace-Util/Context.c')
0 files changed, 0 insertions, 0 deletions