linux/arch/s390
Philipp Rudo 2fba53ccfb s390/kexec_file: fix error handling when applying relocations
[ Upstream commit 41967a37b8eedfee15b81406a9f3015be90d3980 ]

arch_kexec_apply_relocations_add currently ignores all errors returned
by arch_kexec_do_relocs. This means that every unknown relocation is
silently skipped causing unpredictable behavior while the relocated code
runs. Fix this by checking for errors and fail kexec_file_load if an
unknown relocation type is encountered.

The problem was found after gcc changed its behavior and used
R_390_PLT32DBL relocations for brasl instruction and relied on ld to
resolve the relocations in the final link in case direct calls are
possible. As the purgatory code is only linked partially (option -r)
ld didn't resolve the relocations leaving them for arch_kexec_do_relocs.
But arch_kexec_do_relocs doesn't know how to handle R_390_PLT32DBL
relocations so they were silently skipped. This ultimately caused an
endless loop in the purgatory as the brasl instructions kept branching
to itself.

Fixes: 71406883fd ("s390/kexec_file: Add kexec_file_load system call")
Reported-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Philipp Rudo <prudo@redhat.com>
Link: https://lore.kernel.org/r/20211208130741.5821-3-prudo@redhat.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-12-22 09:29:36 +01:00
..
appldata
boot s390/boot: fix use of expolines in the DMA code 2021-07-28 13:30:58 +02:00
configs
crypto
hypfs
include s390/pci: move pseudo-MMIO to prevent MIO overlap 2021-12-08 09:01:11 +01:00
kernel s390/kexec_file: fix error handling when applying relocations 2021-12-22 09:29:36 +01:00
kvm KVM: s390: Fix handle_sske page fault handling 2021-11-17 09:48:39 +01:00
lib s390: fix strrchr() implementation 2021-10-20 11:40:12 +02:00
mm s390/mm: validate VMA in PGSTE manipulation functions 2021-12-01 09:23:34 +01:00
net bpf, s390: Fix potential memory leak about jit_data 2021-10-13 10:08:20 +02:00
numa
oprofile
pci s390/pci_mmio: fully validate the VMA before calling follow_pte() 2021-09-26 14:07:06 +02:00
purgatory
scripts
tools
Kbuild
Kconfig s390: appldata depends on PROC_SYSCTL 2021-07-14 16:53:42 +02:00
Kconfig.debug
Makefile