1
0
Fork 0
alistair23-linux/arch
Qian Cai 96cd8d249a powerpc/64s/pgtable: fix an undefined behaviour
[ Upstream commit c2e929b18c ]

Booting a power9 server with hash MMU could trigger an undefined
behaviour because pud_offset(p4d, 0) will do,

0 >> (PAGE_SHIFT:16 + PTE_INDEX_SIZE:8 + H_PMD_INDEX_SIZE:10)

Fix it by converting pud_index() and friends to static inline
functions.

UBSAN: shift-out-of-bounds in arch/powerpc/mm/ptdump/ptdump.c:282:15
shift exponent 34 is too large for 32-bit type 'int'
CPU: 6 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc4-next-20200303+ #13
Call Trace:
dump_stack+0xf4/0x164 (unreliable)
ubsan_epilogue+0x18/0x78
__ubsan_handle_shift_out_of_bounds+0x160/0x21c
walk_pagetables+0x2cc/0x700
walk_pud at arch/powerpc/mm/ptdump/ptdump.c:282
(inlined by) walk_pagetables at arch/powerpc/mm/ptdump/ptdump.c:311
ptdump_check_wx+0x8c/0xf0
mark_rodata_ro+0x48/0x80
kernel_init+0x74/0x194
ret_from_kernel_thread+0x5c/0x74

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Qian Cai <cai@lca.pw>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Link: https://lore.kernel.org/r/20200306044852.3236-1-cai@lca.pw
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-06-24 17:50:31 +02:00
..
alpha alpha: fix memory barriers so that they conform to the specification 2020-06-22 09:31:21 +02:00
arc ARC: [plat-eznps]: Restrict to CONFIG_ISA_ARCOMPACT 2020-06-07 13:18:50 +02:00
arm ARM: dts: sun8i-h2-plus-bananapi-m2-zero: Fix led polarity 2020-06-24 17:50:20 +02:00
arm64 arm64: tegra: Fix flag for 64-bit resources in 'ranges' property 2020-06-24 17:50:31 +02:00
c6x mm: consolidate pgtable_cache_init() and pgd_cache_init() 2019-09-24 15:54:09 -07:00
csky csky: Fixup abiv2 syscall_trace break a4 & a5 2020-06-17 16:40:21 +02:00
h8300 mm: consolidate pgtable_cache_init() and pgd_cache_init() 2019-09-24 15:54:09 -07:00
hexagon hexagon: define ioremap_uc 2020-05-10 10:31:31 +02:00
ia64 mm/memory_hotplug: shrink zones when offlining memory 2020-01-09 10:19:56 +01:00
m68k m68k/PCI: Fix a memory leak in an error handling path 2020-06-24 17:50:16 +02:00
microblaze microblaze: Prevent the overflow of the start 2020-02-24 08:37:02 +01:00
mips MIPS: Fix IRQ tracing when call handle_fpe() and handle_msa_fpe() 2020-06-22 09:31:09 +02:00
nds32 asm-generic/nds32: don't redefine cacheflush primitives 2020-01-17 19:48:43 +01:00
nios2 nios2 update for v5.4-rc1 2019-09-27 13:02:19 -07:00
openrisc mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
parisc parisc: Fix kernel panic in mem_init() 2020-06-03 08:21:28 +02:00
powerpc powerpc/64s/pgtable: fix an undefined behaviour 2020-06-24 17:50:31 +02:00
riscv riscv: stacktrace: Fix undefined reference to `walk_stackframe' 2020-06-03 08:21:13 +02:00
s390 s390/pci: Log new handle in clp_disable_fh() 2020-06-17 16:40:23 +02:00
sh pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs 2020-02-24 08:36:41 +01:00
sparc sparc32: mm: Don't try to free page-table pages if ctor() fails 2020-06-24 17:50:18 +02:00
um um: ensure `make ARCH=um mrproper` removes arch/$(SUBARCH)/include/generated/ 2020-05-02 08:48:53 +02:00
unicore32 mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
x86 x86/purgatory: Disable various profiling and sanitizing options 2020-06-24 17:50:20 +02:00
xtensa xtensa: Implement copy_thread_tls 2020-01-14 20:08:35 +01:00
.gitignore
Kconfig asm-generic/tlb: add missing CONFIG symbol 2020-02-24 08:37:02 +01:00