• Tejun Heo's avatar
    ptrace,x86: force IRET path after a ptrace_stop() · b9cd18de
    Tejun Heo authored
    The 'sysret' fastpath does not correctly restore even all regular
    registers, much less any segment registers or reflags values.  That is
    very much part of why it's faster than 'iret'.
    
    Normally that isn't a problem, because the normal ptrace() interface
    catches the process using the signal handler infrastructure, which
    always returns with an iret.
    
    However, some paths can get caught using ptrace_event() instead of the
    signal path, and for those we need to make sure that we aren't going to
    return to user space using 'sysret'.  Otherwise the modifications that
    may have been done to the register set by the tracer wouldn't
    necessarily take effect.
    
    Fix it by forcing IRET path by setting TIF_NOTIFY_RESUME from
    arch_ptrace_stop_needed() which is invoked from ptrace_stop().
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reported-by: default avatarAndy Lutomirski <luto@amacapital.net>
    Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
    Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    b9cd18de
ptrace.h 6.77 KB