linux-stable/arch/riscv
Liao Chang 3ca8a07f14 RISC-V: use memcpy for kexec_file mode
[ Upstream commit b7fb4d78a6 ]

The pointer to buffer loading kernel binaries is in kernel space for
kexec_fil mode, When copy_from_user copies data from pointer to a block
of memory, it checkes that the pointer is in the user space range, on
RISCV-V that is:

static inline bool __access_ok(unsigned long addr, unsigned long size)
{
	return size <= TASK_SIZE && addr <= TASK_SIZE - size;
}

and TASK_SIZE is 0x4000000000 for 64-bits, which now causes
copy_from_user to reject the access of the field 'buf' of struct
kexec_segment that is in range [CONFIG_PAGE_OFFSET - VMALLOC_SIZE,
CONFIG_PAGE_OFFSET), is invalid user space pointer.

This patch fixes this issue by skipping access_ok(), use mempcy() instead.

Signed-off-by: Liao Chang <liaochang1@huawei.com>
Link: https://lore.kernel.org/r/20220408100914.150110-3-lizhengyu3@huawei.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-14 18:41:28 +02:00
..
boot riscv: dts: sifive: fu540-c000: align dma node name with dtschema 2022-05-25 09:59:11 +02:00
configs riscv: fix nommu_k210_sdcard_defconfig 2022-02-24 19:22:55 -08:00
errata riscv: errata: alternative: mark vendor_patch_func __initdata 2022-01-09 11:02:46 -08:00
include riscv: Move alternative length validation into subsection 2022-06-09 10:25:13 +02:00
kernel RISC-V: use memcpy for kexec_file mode 2022-06-14 18:41:28 +02:00
kvm RISC-V: KVM: Restrict the extensions that can be disabled 2022-04-27 14:41:03 +02:00
lib riscv: Fixed misaligned memory access. Fixed pointer comparison. 2022-04-13 19:27:21 +02:00
mm RISC-V: Fix the XIP build 2022-06-09 10:26:14 +02:00
net riscv: bpf: Fix eBPF's exception tables 2022-01-19 10:50:02 -08:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig RISC-V Patches for the 5.17 Merge Window, Part 2 2022-01-22 09:34:49 +02:00
Kconfig.debug
Kconfig.erratas riscv: alternative only works on !XIP_KERNEL 2022-03-10 10:05:19 -08:00
Kconfig.socs riscv: alternative only works on !XIP_KERNEL 2022-03-10 10:05:19 -08:00
Makefile riscv: Fixup difference with defconfig 2022-06-09 10:26:11 +02:00