1. 25 4月, 2018 1 次提交
    • E
      signal: Ensure every siginfo we send has all bits initialized · 3eb0f519
      Eric W. Biederman 提交于
      Call clear_siginfo to ensure every stack allocated siginfo is properly
      initialized before being passed to the signal sending functions.
      
      Note: It is not safe to depend on C initializers to initialize struct
      siginfo on the stack because C is allowed to skip holes when
      initializing a structure.
      
      The initialization of struct siginfo in tracehook_report_syscall_exit
      was moved from the helper user_single_step_siginfo into
      tracehook_report_syscall_exit itself, to make it clear that the local
      variable siginfo gets fully initialized.
      
      In a few cases the scope of struct siginfo has been reduced to make it
      clear that siginfo siginfo is not used on other paths in the function
      in which it is declared.
      
      Instances of using memset to initialize siginfo have been replaced
      with calls clear_siginfo for clarity.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      3eb0f519
  2. 24 11月, 2017 1 次提交
  3. 21 11月, 2017 1 次提交
    • R
      x86/umip: Print a warning into the syslog if UMIP-protected instructions are used · fd11a649
      Ricardo Neri 提交于
      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: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NRicardo Neri <ricardo.neri-calderon@linux.intel.com>
      Reviewed-by: NThomas 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: NIngo Molnar <mingo@kernel.org>
      fd11a649
  4. 14 11月, 2017 1 次提交
    • R
      x86/umip: Identify the STR and SLDT instructions · 6e2a3064
      Ricardo Neri 提交于
      The STR and SLDT instructions are not emulated by the UMIP code, thus
      there's no functionality in the decoder to identify them.
      
      However, a subsequent commit will introduce a warning about the use
      of all the instructions that UMIP protect/changes, not only those that
      are emulated.
      
      A first step for that is to add the ability to decode/identify them.
      
      Plus, now that STR and SLDT are identified, we need to explicitly avoid
      their emulation (i.e., not rely on successful identification). Group
      together all the cases that we do not want to emulate: STR, SLDT and user
      long mode processes.
      Signed-off-by: NRicardo Neri <ricardo.neri-calderon@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: ricardo.neri@intel.com
      Link: http://lkml.kernel.org/r/1510640985-18412-4-git-send-email-ricardo.neri-calderon@linux.intel.com
      [ Rewrote the changelog, fixed ugly col80 artifact. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      6e2a3064
  5. 08 11月, 2017 2 次提交
    • R
      x86/umip: Force a page fault when unable to copy emulated result to user · c6a960bb
      Ricardo Neri 提交于
      fixup_umip_exception() will be called from do_general_protection(). If the
      former returns false, the latter will issue a SIGSEGV with SEND_SIG_PRIV.
      However, when emulation is successful but the emulated result cannot be
      copied to user space memory, it is more accurate to issue a SIGSEGV with
      SEGV_MAPERR with the offending address. A new function, inspired in
      force_sig_info_fault(), is introduced to model the page fault.
      Signed-off-by: NRicardo Neri <ricardo.neri-calderon@linux.intel.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      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: Chen Yucong <slaoub@gmail.com>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Huang Rui <ray.huang@amd.com>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: ricardo.neri@intel.com
      Link: http://lkml.kernel.org/r/1509935277-22138-9-git-send-email-ricardo.neri-calderon@linux.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c6a960bb
    • R
      x86/umip: Add emulation code for UMIP instructions · 1e5db223
      Ricardo Neri 提交于
      The feature User-Mode Instruction Prevention present in recent Intel
      processor prevents a group of instructions (sgdt, sidt, sldt, smsw, and
      str) from being executed with CPL > 0. Otherwise, a general protection
      fault is issued.
      
      Rather than relaying to the user space the general protection fault caused
      by the UMIP-protected instructions (in the form of a SIGSEGV signal), it
      can be trapped and the instruction emulated to provide a dummy result.
      This allows to both conserve the current kernel behavior and not reveal the
      system resources that UMIP intends to protect (i.e., the locations of the
      global descriptor and interrupt descriptor tables, the segment selectors of
      the local descriptor table, the value of the task state register and the
      contents of the CR0 register).
      
      This emulation is needed because certain applications (e.g., WineHQ and
      DOSEMU2) rely on this subset of instructions to function. Given that sldt
      and str are not commonly used in programs that run on WineHQ or DOSEMU2,
      they are not emulated. Also, emulation is provided only for 32-bit
      processes; 64-bit processes that attempt to use the instructions that UMIP
      protects will receive the SIGSEGV signal issued as a consequence of the
      general protection fault.
      
      The instructions protected by UMIP can be split in two groups. Those which
      return a kernel memory address (sgdt and sidt) and those which return a
      value (smsw, sldt and str; the last two not emulated).
      
      For the instructions that return a kernel memory address, applications such
      as WineHQ rely on the result being located in the kernel memory space, not
      the actual location of the table. The result is emulated as a hard-coded
      value that lies close to the top of the kernel memory. The limit for the
      GDT and the IDT are set to zero.
      
      The instruction smsw is emulated to return the value that the register CR0
      has at boot time as set in the head_32.
      
      Care is taken to appropriately emulate the results when segmentation is
      used. That is, rather than relying on USER_DS and USER_CS, the function
      insn_get_addr_ref() inspects the segment descriptor pointed by the
      registers in pt_regs. This ensures that we correctly obtain the segment
      base address and the address and operand sizes even if the user space
      application uses a local descriptor table.
      Signed-off-by: NRicardo Neri <ricardo.neri-calderon@linux.intel.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      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: Chen Yucong <slaoub@gmail.com>
      Cc: Chris Metcalf <cmetcalf@mellanox.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Huang Rui <ray.huang@amd.com>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: ricardo.neri@intel.com
      Link: http://lkml.kernel.org/r/1509935277-22138-8-git-send-email-ricardo.neri-calderon@linux.intel.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1e5db223