WSL2-Linux-Kernel/arch/powerpc/mm/ptdump
Michael Ellerman b14b8b1ed0 powerpc/ptdump: Fix generic ptdump for 64-bit
Since the conversion to generic ptdump we see crashes on 64-bit:

  BUG: Unable to handle kernel data access on read at 0xc0eeff7f00000000
  Faulting instruction address: 0xc00000000045e5fc
  Oops: Kernel access of bad area, sig: 11 [#1]
  ...
  NIP __walk_page_range+0x2bc/0xce0
  LR  __walk_page_range+0x240/0xce0
  Call Trace:
    __walk_page_range+0x240/0xce0 (unreliable)
    walk_page_range_novma+0x74/0xb0
    ptdump_walk_pgd+0x98/0x170
    ptdump_check_wx+0x88/0xd0
    mark_rodata_ro+0x48/0x80
    kernel_init+0x74/0x1a0
    ret_from_kernel_thread+0x5c/0x64

What's happening is that have walked off the end of the kernel page
tables, and started dereferencing junk values.

That happens because we initialised the ptdump_range to span all the way
up to 0xffffffffffffffff:

static struct ptdump_range ptdump_range[] __ro_after_init = {
	{TASK_SIZE_MAX, ~0UL},

But the kernel page tables don't span that far. So on 64-bit set the end
of the range to be the address immediately past the end of the kernel
page tables, to limit the page table walk to valid addresses.

Fixes: e084728393 ("powerpc/ptdump: Convert powerpc to GENERIC_PTDUMP")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210831135151.886620-1-mpe@ellerman.id.au
2021-09-01 16:52:53 +10:00
..
8xx.c powerpc/ptdump: Reduce level numbers by 1 in note_page() and add p4d level 2021-08-25 13:35:48 +10:00
Makefile powerpc/ptdump: Convert powerpc to GENERIC_PTDUMP 2021-08-25 13:35:48 +10:00
bats.c powerpc/ptdump: Use DEFINE_SHOW_ATTRIBUTE() 2021-08-25 13:35:48 +10:00
book3s64.c powerpc/ptdump: Reduce level numbers by 1 in note_page() and add p4d level 2021-08-25 13:35:48 +10:00
hashpagetable.c powerpc/ptdump: Use DEFINE_SHOW_ATTRIBUTE() 2021-08-25 13:35:48 +10:00
ptdump.c powerpc/ptdump: Fix generic ptdump for 64-bit 2021-09-01 16:52:53 +10:00
ptdump.h powerpc/ptdump: Display size of BATs 2020-05-26 22:22:18 +10:00
segment_regs.c powerpc/ptdump: Use DEFINE_SHOW_ATTRIBUTE() 2021-08-25 13:35:48 +10:00
shared.c powerpc/ptdump: Reduce level numbers by 1 in note_page() and add p4d level 2021-08-25 13:35:48 +10:00