Skip to content

Commit

Permalink
x86/cpu_entry_area: Prevent wraparound in setup_cpu_entry_area_ptes()…
Browse files Browse the repository at this point in the history
… on 32bit

The loop which populates the CPU entry area PMDs can wrap around on 32bit
machines when the number of CPUs is small.

It worked wonderful for NR_CPUS=64 for whatever reason and the moron who
wrote that code did not bother to test it with !SMP.

Check for the wraparound to fix it.

Fixes: 92a0f81 ("x86/cpu_entry_area: Move it out of the fixmap")
Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Thomas "Feels stupid" Gleixner <tglx@linutronix.de>
Tested-by: Borislav Petkov <bp@alien8.de>
  • Loading branch information
KAGA-KOKO committed Dec 23, 2017
1 parent 613e396 commit f6c4fd5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/mm/cpu_entry_area.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ static __init void setup_cpu_entry_area_ptes(void)
start = CPU_ENTRY_AREA_BASE;
end = start + CPU_ENTRY_AREA_MAP_SIZE;

for (; start < end; start += PMD_SIZE)
/* Careful here: start + PMD_SIZE might wrap around */
for (; start < end && start >= CPU_ENTRY_AREA_BASE; start += PMD_SIZE)
populate_extra_pte(start);
#endif
}
Expand Down

0 comments on commit f6c4fd5

Please sign in to comment.