linux-stable/arch/riscv
Liao Chang 3ba83e46b5 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:45:03 +02:00
..
boot RISC-V Fixes for 5.18 2022-05-20 08:13:32 -10:00
configs RISC-V: configs: Configs that had RPMSG_CHAR now get RPMSG_CTRL 2022-04-26 08:19:53 -07:00
errata
include RISC-V: Split out the XIP fixups into their own file 2022-06-09 10:30:37 +02:00
kernel RISC-V: use memcpy for kexec_file mode 2022-06-14 18:45:03 +02:00
kvm Merge branch 'kvm-fixes-for-5.18-rc5' into HEAD 2022-04-29 12:39:34 -04:00
lib
mm RISC-V: Fix the XIP build 2022-06-09 10:30:38 +02:00
net
Kbuild
Kconfig RISC-V CPU Idle Support 2022-03-30 16:17:54 -07:00
Kconfig.debug
Kconfig.erratas
Kconfig.socs RISC-V: cpuidle: fix Kconfig select for RISCV_SBI_CPUIDLE 2022-04-21 15:10:47 -07:00
Makefile riscv: Fixup difference with defconfig 2022-06-09 10:30:34 +02:00