WSL2-Linux-Kernel/arch
Zhang Yanfei e9d0626ed4 x86-64, init: Fix a possible wraparound bug in switchover in head_64.S
In head_64.S, a switchover has been used to handle kernel crossing
1G, 512G boundaries.

And commit 8170e6bed4
    x86, 64bit: Use a #PF handler to materialize early mappings on demand
said:
    During the switchover in head_64.S, before #PF handler is available,
    we use three pages to handle kernel crossing 1G, 512G boundaries with
    sharing page by playing games with page aliasing: the same page is
    mapped twice in the higher-level tables with appropriate wraparound.

But from the switchover code, when we set up the PUD table:
114         addq    $4096, %rdx
115         movq    %rdi, %rax
116         shrq    $PUD_SHIFT, %rax
117         andl    $(PTRS_PER_PUD-1), %eax
118         movq    %rdx, (4096+0)(%rbx,%rax,8)
119         movq    %rdx, (4096+8)(%rbx,%rax,8)

It seems line 119 has a potential bug there. For example,
if the kernel is loaded at physical address 511G+1008M, that is
    000000000 111111111 111111000 000000000000000000000
and the kernel _end is 512G+2M, that is
    000000001 000000000 000000001 000000000000000000000
So in this example, when using the 2nd page to setup PUD (line 114~119),
rax is 511.
In line 118, we put rdx which is the address of the PMD page (the 3rd page)
into entry 511 of the PUD table. But in line 119, the entry we calculate from
(4096+8)(%rbx,%rax,8) has exceeded the PUD page. IMO, the entry in line
119 should be wraparound into entry 0 of the PUD table.

The patch fixes the bug.

Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Link: http://lkml.kernel.org/r/5191DE5A.3020302@cn.fujitsu.com
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: <stable@vger.kernel.org> v3.9
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-05-28 15:41:59 -07:00
..
alpha Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
arc Aliasing VIPT dcache support for ARC 2013-05-10 07:24:14 -07:00
arm Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm 2013-05-15 13:37:54 -07:00
arm64 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-10 09:21:05 -07:00
avr32 Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
blackfin blackfin updates for Linux 3.10 2013-05-10 07:21:16 -07:00
c6x dump_stack: unify debug information printed by show_regs() 2013-04-30 17:04:02 -07:00
cris - Lots of cleanups from Artem, including deletion of some obsolete drivers 2013-05-09 10:15:46 -07:00
frv Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
h8300 We get rid of the general module prefix confusion with a binary config option, 2013-05-05 10:58:06 -07:00
hexagon Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
ia64 Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
m32r Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
m68k - Artem's removal of dead code continues (RPX, MBX860) 2013-05-10 09:09:47 -07:00
metag Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
microblaze Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblaze 2013-05-10 07:19:52 -07:00
mips Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-10 09:21:05 -07:00
mn10300 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2013-05-01 14:08:52 -07:00
openrisc Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
parisc parisc: make default cross compiler search more robust (v3) 2013-05-13 22:11:57 +02:00
powerpc Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc 2013-05-14 07:43:11 -07:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-10 09:21:05 -07:00
score Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-01 17:51:54 -07:00
sh Removal of GENERIC_GPIO for v3.10 2013-05-09 09:59:16 -07:00
sparc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-10 09:21:05 -07:00
tile Merge branch 'stable' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2013-05-09 14:34:58 -07:00
um Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-05-07 15:14:53 -07:00
unicore32 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2013-05-10 09:21:05 -07:00
x86 x86-64, init: Fix a possible wraparound bug in switchover in head_64.S 2013-05-28 15:41:59 -07:00
xtensa Xtensa patchset for v3.10-rc1 2013-05-09 14:38:16 -07:00
.gitignore
Kconfig Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2013-05-15 14:04:00 -07:00