mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
riscv/mm: Prevent kernel module to access user memory without uaccess routines
We found this issue in an legacy out-of-tree kernel module which didn't properly access user space pointer by get/put_user(). Such an illegal access loops in the page fault handler. To resolve this, let it die here. Signed-off-by: Eric Lin <tesheng@andestech.com> Reviewed-by: Pekka Enberg <penberg@kernel.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
This commit is contained in:
parent
21733cb518
commit
21855cac82
@ -243,6 +243,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
|
||||
if (user_mode(regs))
|
||||
flags |= FAULT_FLAG_USER;
|
||||
|
||||
if (!user_mode(regs) && addr < TASK_SIZE &&
|
||||
unlikely(!(regs->status & SR_SUM)))
|
||||
die_kernel_fault("access to user memory without uaccess routines",
|
||||
addr, regs);
|
||||
|
||||
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
|
||||
|
||||
if (cause == EXC_STORE_PAGE_FAULT)
|
||||
|
Loading…
Reference in New Issue
Block a user