• Ricardo Neri's avatar
    x86/umip: Print a warning into the syslog if UMIP-protected instructions are used · fd11a649
    Ricardo Neri authored
    Print a rate-limited warning when a user-space program attempts to execute
    any of the instructions that UMIP protects (i.e., SGDT, SIDT, SLDT, STR
    and SMSW).
    
    This is useful, because when CONFIG_X86_INTEL_UMIP=y is selected and
    supported by the hardware, user space programs that try to execute such
    instructions will receive a SIGSEGV signal that they might not expect.
    
    In the specific cases for which emulation is provided (instructions SGDT,
    SIDT and SMSW in protected and virtual-8086 modes), no signal is
    generated. However, a warning is helpful to encourage updates in such
    programs to avoid the use of such instructions.
    
    Warnings are printed via a customized printk() function that also provides
    information about the program that attempted to use the affected
    instructions.
    
    Utility macros are defined to wrap umip_printk() for the error and warning
    kernel log levels.
    
    While here, replace an existing call to the generic rate-limited pr_err()
    with the new umip_pr_err().
    Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarRicardo Neri <ricardo.neri-calderon@linux.intel.com>
    Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: ricardo.neri@intel.com
    Link: http://lkml.kernel.org/r/1511233476-17088-1-git-send-email-ricardo.neri-calderon@linux.intel.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    fd11a649
umip.c 14.2 KB