• A
    x86/entry: Vastly simplify SYSENTER TF (single-step) handling · f2b37575
    Andy Lutomirski 提交于
    Due to a blatant design error, SYSENTER doesn't clear TF (single-step).
    
    As a result, if a user does SYSENTER with TF set, we will single-step
    through the kernel until something clears TF.  There is absolutely
    nothing we can do to prevent this short of turning off SYSENTER [1].
    
    Simplify the handling considerably with two changes:
    
      1. We already sanitize EFLAGS in SYSENTER to clear NT and AC.  We can
         add TF to that list of flags to sanitize with no overhead whatsoever.
    
      2. Teach do_debug() to ignore single-step traps in the SYSENTER prologue.
    
    That's all we need to do.
    
    Don't get too excited -- our handling is still buggy on 32-bit
    kernels.  There's nothing wrong with the SYSENTER code itself, but
    the #DB prologue has a clever fixup for traps on the very first
    instruction of entry_SYSENTER_32, and the fixup doesn't work quite
    correctly.  The next two patches will fix that.
    
    [1] We could probably prevent it by forcing BTF on at all times and
        making sure we clear TF before any branches in the SYSENTER
        code.  Needless to say, this is a bad idea.
    Signed-off-by: NAndy Lutomirski <luto@kernel.org>
    Cc: Andrew Cooper <andrew.cooper3@citrix.com>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/a30d2ea06fe4b621fe6a9ef911b02c0f38feb6f2.1457578375.git.luto@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
    f2b37575
entry_32.S 25.5 KB