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

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 proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
boot s390/boot: fix use of expolines in the DMA code 2021-07-28 13:30:58 +02:00
configs s390: update defconfigs 2019-10-04 16:37:33 +02:00
crypto s390/archrandom: add parameter check for s390_arch_random_generate 2021-05-11 14:04:13 +02:00
hypfs Merge branch 'work.mount3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2019-09-24 12:33:34 -07:00
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 s390/numa: set node distance to LOCAL_DISTANCE 2020-09-03 11:26:50 +02:00
oprofile s390/unwind: introduce stack unwind API 2019-05-02 13:54:11 +02:00
pci s390/pci_mmio: fully validate the VMA before calling follow_pte() 2021-09-26 14:07:06 +02:00
purgatory s390/kexec_file: fix diag308 subcode when loading crash kernel 2020-12-30 11:51:34 +01:00
scripts s390/build: use size command to perform empty .bss check 2019-08-08 14:36:53 +02:00
tools s390: add support for IBM z15 machines 2019-09-13 12:19:14 +02:00
Kbuild
Kconfig s390: appldata depends on PROC_SYSCTL 2021-07-14 16:53:42 +02:00
Kconfig.debug
Makefile s390: make 'install' not depend on vmlinux 2020-03-12 13:00:13 +01:00