• James Hogan's avatar
    MIPS: do_mcheck: Fix kernel code dump with EVA · cf387a0e
    James Hogan authored
    commit 55c723e1 upstream.
    
    If a machine check exception is raised in kernel mode, user context,
    with EVA enabled, then the do_mcheck handler will attempt to read the
    code around the EPC using EVA load instructions, i.e. as if the reads
    were from user mode. This will either read random user data if the
    process has anything mapped at the same address, or it will cause an
    exception which is handled by __get_user, resulting in this output:
    
     Code: (Bad address in epc)
    
    Fix by setting the current user access mode to kernel if the saved
    register context indicates the exception was taken in kernel mode. This
    causes __get_user to use normal loads to read the kernel code.
    Signed-off-by: default avatarJames Hogan <james.hogan@imgtec.com>
    Cc: Markos Chandras <markos.chandras@imgtec.com>
    Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/10777/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
    Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
    cf387a0e
traps.c 52.8 KB