lkml.org 
[lkml]   [2020]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] riscv/mm: Prevent kernel module access user-space memory without uaccess routines
    Date
    In the page fault handler, an access to user-space memory
    without get/put_user() or copy_from/to_user() routines is
    not resolved properly. Like arm and other architectures,
    we need to let it die earlier in page fault handler.

    Signed-off-by: Eric Lin <tesheng@andestech.com>
    Cc: Alan Kao <alankao@andestech.com>
    ---
    arch/riscv/mm/fault.c | 3 +++
    1 file changed, 3 insertions(+)

    diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
    index 3c8b9e433c67..a452cfa266a2 100644
    --- a/arch/riscv/mm/fault.c
    +++ b/arch/riscv/mm/fault.c
    @@ -232,6 +232,9 @@ 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(regs, "Accessing user space memory without uaccess routines\n");
    +
    perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);

    if (cause == EXC_STORE_PAGE_FAULT)
    --
    2.17.0
    \
     
     \ /
      Last update: 2020-11-30 07:02    [W:2.991 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site