linux/arch/parisc/kernel
Helge Deller 8b1d723956 parisc: Fix random data corruption from exception handler
The current exception handler implementation, which assists when accessing
user space memory, may exhibit random data corruption if the compiler decides
to use a different register than the specified register %r29 (defined in
ASM_EXCEPTIONTABLE_REG) for the error code. If the compiler choose another
register, the fault handler will nevertheless store -EFAULT into %r29 and thus
trash whatever this register is used for.
Looking at the assembly I found that this happens sometimes in emulate_ldd().

To solve the issue, the easiest solution would be if it somehow is
possible to tell the fault handler which register is used to hold the error
code. Using %0 or %1 in the inline assembly is not posssible as it will show
up as e.g. %r29 (with the "%r" prefix), which the GNU assembler can not
convert to an integer.

This patch takes another, better and more flexible approach:
We extend the __ex_table (which is out of the execution path) by one 32-word.
In this word we tell the compiler to insert the assembler instruction
"or %r0,%r0,%reg", where %reg references the register which the compiler
choosed for the error return code.
In case of an access failure, the fault handler finds the __ex_table entry and
can examine the opcode. The used register is encoded in the lowest 5 bits, and
the fault handler can then store -EFAULT into this register.

Since we extend the __ex_table to 3 words we can't use the BUILDTIME_TABLE_SORT
config option any longer.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: <stable@vger.kernel.org> # v6.0+
2024-01-30 17:18:58 +01:00
..
syscalls lsm/stable-6.8 PR 20240105 2024-01-09 12:57:46 -08:00
vdso32 parisc: Add missing FORCE prerequisites in Makefile 2022-12-18 22:18:49 +01:00
vdso64 parisc: Add missing FORCE prerequisites in Makefile 2022-12-18 22:18:49 +01:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
alternative.c parisc: Use num_present_cpus() in alternative patching code 2023-05-23 18:17:32 +02:00
asm-offsets.c parisc: Prepare for Block-TLB support on 32-bit kernel 2023-09-07 09:12:19 +02:00
audit.c parisc: Fold 32-bit compat code into audit_classify_syscall() 2023-06-30 17:14:14 +02:00
cache.c parisc: Fix random data corruption from exception handler 2024-01-30 17:18:58 +01:00
compat_audit.c parisc: Fold 32-bit compat code into audit_classify_syscall() 2023-06-30 17:14:14 +02:00
drivers.c parisc: Drop unneeded semicolon in parse_tree_node() 2024-01-28 09:49:47 +01:00
entry.S parisc/pgtable: Do not drop upper 5 address bits of physical address 2023-11-07 19:48:30 +01:00
firmware.c parisc/firmware: Fix F-extend for PDC addresses 2024-01-07 22:59:16 +01:00
ftrace.c parisc: ftrace: Add declaration for ftrace_function_trampoline() 2023-08-10 22:51:54 +02:00
hardware.c parisc: Clean up names in hardware database 2022-08-01 18:43:23 +02:00
head.S parisc: Prevent booting 64-bit kernels on PA1.x machines 2023-11-10 16:17:32 +01:00
hpmc.S parisc: Re-use toc_stack as hpmc_stack 2022-01-11 11:57:37 +01:00
inventory.c parisc: Add qemu fw_cfg interface 2020-10-15 08:10:37 +02:00
irq.c parisc: irq: Make irq_stack_union static to avoid sparse warning 2023-08-31 22:36:12 +02:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kexec_file.c kexec_file, parisc: print out debugging message if required 2023-12-20 15:02:57 -08:00
kexec.c parisc: kexec: include reboot.h 2023-05-09 14:04:56 +02:00
kgdb.c parisc: Drop duplicate kgdb_pdc console 2022-12-18 22:18:49 +01:00
kprobes.c parisc: Fix typos in comments 2022-05-08 20:01:12 +02:00
Makefile parisc: Drop the pa7300lc LPMC handler 2023-08-20 20:23:46 +02:00
module.c parisc: module: Mark symindex __maybe_unused 2023-06-30 17:14:14 +02:00
pacache.S parisc: Ensure page alignment in flush functions 2023-05-03 17:43:26 +02:00
parisc_ksyms.c parisc: parisc_ksyms: Include libgcc.h for libgcc prototypes 2023-08-10 18:34:05 +02:00
patch.c parisc: Fix patch code locking and flushing 2022-05-17 21:52:59 +02:00
pci-dma.c parisc: Move proc_mckinley_root and proc_runway_root to sba_iommu 2023-08-10 22:22:03 +02:00
pci.c parisc: Drop comments which are already in pci.h 2019-09-05 16:41:11 +02:00
pdc_chassis.c parisc: chassis: Do not overwrite string on LCD display 2023-08-28 17:58:14 +02:00
pdc_cons.c parisc: Drop locking in pdc console code 2022-12-18 22:18:49 +01:00
pdt.c parisc: pdt: Use PTR_ERR_OR_ZERO() to simplify code 2023-08-10 17:32:09 +02:00
perf_asm.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
perf_images.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
perf.c parisc: perf: Make cpu_device variable static 2023-08-10 23:00:18 +02:00
process.c parisc: Use generic mmap top-down layout and brk randomization 2023-08-22 10:24:46 +02:00
processor.c parisc: Replace strlcpy() with strscpy() 2023-11-18 18:59:28 +01:00
ptrace.c parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case 2023-02-01 21:42:37 +01:00
real2.S parisc: Fix argument pointer in real64_call_asm() 2023-05-03 17:43:26 +02:00
relocate_kernel.S parisc: add kexec syscall support 2019-09-08 15:37:04 +02:00
setup.c parisc: Move parisc_narrow_firmware variable to header file 2023-10-30 14:54:40 +01:00
signal32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
signal32.h parisc: Add vDSO support 2022-03-11 19:49:30 +01:00
signal.c parisc: signal: Fix sparse incorrect type in assignment warning 2023-08-10 17:32:10 +02:00
smp.c parisc: simplify smp_prepare_boot_cpu() 2023-10-30 14:54:41 +01:00
stacktrace.c parisc: Fix implicit declaration of function '__kernel_text_address' 2021-11-13 22:10:56 +01:00
sys_parisc32.c
sys_parisc.c parisc: fix mmap_base calculation when stack grows upwards 2023-11-15 15:30:09 -08:00
syscall.S parisc: Fix lightweight spinlock checks to not break futexes 2023-08-10 17:32:09 +02:00
time.c parisc: Mark cr16 clock unstable on all SMP machines 2022-05-08 20:01:12 +02:00
toc_asm.S parisc: Enable TOC (transfer of contents) feature unconditionally 2022-01-11 11:57:37 +01:00
toc.c parisc: Fix missing prototype for 'toc_intr' warning in toc.c 2022-01-20 20:39:19 +01:00
topology.c parisc: fix a crash with multicore scheduler 2022-06-03 09:54:01 +02:00
traps.c parisc: traps: Drop cpu_lpmc function pointer 2023-08-20 20:23:46 +02:00
unaligned.c parisc: Fix random data corruption from exception handler 2024-01-30 17:18:58 +01:00
unwind.c parisc: unwind: Avoid missing prototype warning for handle_interruption() 2023-07-03 18:56:03 +02:00
vdso.c treewide: use get_random_u32_below() instead of deprecated function 2022-11-18 02:15:15 +01:00
vmlinux.lds.S parisc: Make RO_DATA page aligned in vmlinux.lds.S 2024-01-28 09:49:46 +01:00