lkml.org 
[lkml]   [2020]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [PATCH v2] x86/dumpstack: Fix misleading instruction pointer error message
    On 10/02, Mark Mossberg wrote:
    >
    > Printing "Bad RIP value" if copy_code() fails can be misleading for
    > userspace pointers, since copy_code() can fail if the instruction
    > pointer is valid, but the code is paged out.

    Another problem is that show_opcodes() makes no sense if user_mode(regs)
    and tsk is not current. Try "echo t > /proc/sysrq-trigger".

    In this case copy_from_user_nmi() will either fail, or (worse) it will
    read the "random" memory from current->mm.

    Perhaps we can add something like

    if (user_mode(regs) && regs != task_pt_regs(current))
    return;

    at the start of show_opcodes() ?

    > --- a/arch/x86/kernel/dumpstack.c
    > +++ b/arch/x86/kernel/dumpstack.c
    > @@ -115,7 +115,8 @@ void show_opcodes(struct pt_regs *regs, const char *loglvl)
    > unsigned long prologue = regs->ip - PROLOGUE_SIZE;
    >
    > if (copy_code(regs, opcodes, prologue, sizeof(opcodes))) {
    > - printk("%sCode: Bad RIP value.\n", loglvl);
    > + printk("%sCode: Unable to access opcode bytes at RIP 0x%lx.\n",
    > + loglvl, prologue);
    > } else {
    > printk("%sCode: %" __stringify(PROLOGUE_SIZE) "ph <%02x> %"
    > __stringify(EPILOGUE_SIZE) "ph\n", loglvl, opcodes,
    > --
    > 2.25.1
    >

    \
     
     \ /
      Last update: 2020-11-03 13:51    [W:7.526 / U:0.220 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site