16 Mar, 2017

1 commit

  • Each processor holds a GDT in its per-cpu structure. The sgdt
    instruction gives the base address of the current GDT. This address can
    be used to bypass KASLR memory randomization. With another bug, an
    attacker could target other per-cpu structures or deduce the base of
    the main memory section (PAGE_OFFSET).

    This patch relocates the GDT table for each processor inside the
    fixmap section. The space is reserved based on number of supported
    processors.

    For consistency, the remapping is done by default on 32 and 64-bit.

    Each processor switches to its remapped GDT at the end of
    initialization. For hibernation, the main processor returns with the
    original GDT and switches back to the remapping at completion.

    This patch was tested on both architectures. Hibernation and KVM were
    both tested specially for their usage of the GDT.

    Thanks to Boris Ostrovsky for testing and
    recommending changes for Xen support.

    Signed-off-by: Thomas Garnier
    Cc: Alexander Potapenko
    Cc: Andrew Morton
    Cc: Andrey Ryabinin
    Cc: Andy Lutomirski
    Cc: Ard Biesheuvel
    Cc: Boris Ostrovsky
    Cc: Borislav Petkov
    Cc: Chris Wilson
    Cc: Christian Borntraeger
    Cc: Dmitry Vyukov
    Cc: Frederic Weisbecker
    Cc: Jiri Kosina
    Cc: Joerg Roedel
    Cc: Jonathan Corbet
    Cc: Josh Poimboeuf
    Cc: Juergen Gross
    Cc: Kees Cook
    Cc: Len Brown
    Cc: Linus Torvalds
    Cc: Lorenzo Stoakes
    Cc: Luis R . Rodriguez
    Cc: Matt Fleming
    Cc: Michal Hocko
    Cc: Paolo Bonzini
    Cc: Paul Gortmaker
    Cc: Pavel Machek
    Cc: Peter Zijlstra
    Cc: Radim Krčmář
    Cc: Rafael J . Wysocki
    Cc: Rusty Russell
    Cc: Stanislaw Gruszka
    Cc: Thomas Gleixner
    Cc: Tim Chen
    Cc: Vitaly Kuznetsov
    Cc: kasan-dev@googlegroups.com
    Cc: kernel-hardening@lists.openwall.com
    Cc: kvm@vger.kernel.org
    Cc: lguest@lists.ozlabs.org
    Cc: linux-doc@vger.kernel.org
    Cc: linux-efi@vger.kernel.org
    Cc: linux-mm@kvack.org
    Cc: linux-pm@vger.kernel.org
    Cc: xen-devel@lists.xenproject.org
    Cc: zijun_hu
    Link: http://lkml.kernel.org/r/20170314170508.100882-2-thgarnie@google.com
    Signed-off-by: Ingo Molnar

    Thomas Garnier
     

25 Dec, 2016

1 commit


01 Nov, 2016

1 commit

  • Now that Linux never sets CR0.TS, lguest doesn't need to support it.

    Signed-off-by: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Dave Hansen
    Cc: Denys Vlasenko
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Paolo Bonzini
    Cc: Peter Zijlstra
    Cc: Quentin Casasnovas
    Cc: Rik van Riel
    Cc: Rusty Russell
    Cc: Thomas Gleixner
    Cc: kvm list
    Link: http://lkml.kernel.org/r/8a7bf2c11231c082258fd67705d0f275639b8475.1477951965.git.luto@kernel.org
    Signed-off-by: Ingo Molnar

    Andy Lutomirski
     

13 Apr, 2016

1 commit


01 Apr, 2016

1 commit

  • In a798f091113e ("x86/entry/32: Change INT80 to be an interrupt gate")
    Andy broke lguest. This is because lguest had special code to allow
    the 0x80 trap gate go straight into the guest itself; interrupts gates
    (without more work, as mentioned in the file's comments) bounce via
    the hypervisor.

    His change made them go via the hypervisor, but as it's in the range of
    normal hardware interrupts, they were not directed through to the guest
    at all. Turns out the guest userspace isn't very effective if syscalls
    are all noops.

    I haven't ripped out all the now-useless trap-direct-to-guest-kernel
    code yet, since it will still be needed if someone decides to update
    this optimization.

    Signed-off-by: Rusty Russell
    Cc: Andy Lutomirski
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Weisbecker
    Cc: x86\@kernel.org
    Link: http://lkml.kernel.org/r/87fuv685kl.fsf@rustcorp.com.au
    Signed-off-by: Ingo Molnar

    Rusty Russell
     

31 Mar, 2016

1 commit

  • Use static_cpu_has() in __flush_tlb_all() due to the time-sensitivity of
    this one.

    Signed-off-by: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1459266123-21878-10-git-send-email-bp@alien8.de
    Signed-off-by: Ingo Molnar

    Borislav Petkov
     

19 May, 2015

5 commits

  • This cleans up the call sites and the function a bit,
    and also makes it more symmetric with the other high
    level FPU state handling functions.

    It's still only valid for the current task, as we copy
    to the FPU registers of the current CPU.

    No change in functionality.

    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Rename this function in line with the new FPU nomenclature.

    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • There are a number of FPU internal function prototypes and an inline function
    in fpu/api.h, mostly placed so historically as the code grew over the years.

    Move them over into fpu/internal.h where they belong. (Add sched.h include
    to stackprotector.h which incorrectly relied on getting it from fpu/api.h.)

    fpu/api.h is now a pure file that only contains FPU APIs intended for driver
    use.

    Reviewed-by: Borislav Petkov
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • We already have fpu/types.h, move i387.h to fpu/api.h.

    The file name has become a misnomer anyway: it offers generic FPU APIs,
    but is not limited to i387 functionality.

    Reviewed-by: Borislav Petkov
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Move to the new fpu__*() namespace.

    Reviewed-by: Borislav Petkov
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

19 Feb, 2015

1 commit

  • Pull virtio updates from Rusty Russell:
    "OK, this has the big virtio 1.0 implementation, as specified by OASIS.

    On top of tht is the major rework of lguest, to use PCI and virtio
    1.0, to double-check the implementation.

    Then comes the inevitable fixes and cleanups from that work"

    * tag 'virtio-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: (80 commits)
    virtio: don't set VIRTIO_CONFIG_S_DRIVER_OK twice.
    virtio_net: unconditionally define struct virtio_net_hdr_v1.
    tools/lguest: don't use legacy definitions for net device in example launcher.
    virtio: Don't expose legacy net features when VIRTIO_NET_NO_LEGACY defined.
    tools/lguest: use common error macros in the example launcher.
    tools/lguest: give virtqueues names for better error messages
    tools/lguest: more documentation and checking of virtio 1.0 compliance.
    lguest: don't look in console features to find emerg_wr.
    tools/lguest: don't start devices until DRIVER_OK status set.
    tools/lguest: handle indirect partway through chain.
    tools/lguest: insert driver references from the 1.0 spec (4.1 Virtio Over PCI)
    tools/lguest: insert device references from the 1.0 spec (4.1 Virtio Over PCI)
    tools/lguest: rename virtio_pci_cfg_cap field to match spec.
    tools/lguest: fix features_accepted logic in example launcher.
    tools/lguest: handle device reset correctly in example launcher.
    virtual: Documentation: simplify and generalize paravirt_ops.txt
    lguest: remove NOTIFY call and eventfd facility.
    lguest: remove NOTIFY facility from demonstration launcher.
    lguest: use the PCI console device's emerg_wr for early boot messages.
    lguest: always put console in PCI slot #1.
    ...

    Linus Torvalds
     

11 Feb, 2015

3 commits


04 Feb, 2015

1 commit

  • CR4 manipulation was split, seemingly at random, between direct
    (write_cr4) and using a helper (set/clear_in_cr4). Unfortunately,
    the set_in_cr4 and clear_in_cr4 helpers also poke at the boot code,
    which only a small subset of users actually wanted.

    This patch replaces all cr4 access in functions that don't leave cr4
    exactly the way they found it with new helpers cr4_set_bits,
    cr4_clear_bits, and cr4_set_bits_and_update_boot.

    Signed-off-by: Andy Lutomirski
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrea Arcangeli
    Cc: Vince Weaver
    Cc: "hillf.zj"
    Cc: Valdis Kletnieks
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    Cc: Kees Cook
    Cc: Linus Torvalds
    Link: http://lkml.kernel.org/r/495a10bdc9e67016b8fd3945700d46cfd5c12c2f.1414190806.git.luto@amacapital.net
    Signed-off-by: Ingo Molnar

    Andy Lutomirski
     

07 Nov, 2013

1 commit


26 Jun, 2013

1 commit


22 Apr, 2013

2 commits


19 Sep, 2012

1 commit


06 Dec, 2011

1 commit

  • The x86_64 kernel pushes the fake kernel stack in
    arch/x86/kernel/entry_64.S:FAKE_STACK_FRAME, and
    rflags register in it does not conform to the specification.

    Although Intel's manual[1] says bit 1 of it shall be set to 1,
    this bit is cleared to 0 on pushing the fake stack.

    [1] Intel(R) 64 and IA-32 Architectures Software Developer's Manual
    Vol.1 3-21 Figure 3-8. EFLAGS Register

    If it is not on purpose, it is better to be fixed, because
    it can lead some tools misunderstanding the stack frame. For example,
    "crash" utility[2] actually detects it and warns you like
    below:

    RIP: ffffffff8005dfa2 RSP: ffff8104ce0c7f58 RFLAGS: 00000200
    [...]

    bt: WARNING: possibly bogus exception frame

    Signed-off-by: Seiichi Ikarashi
    Tested-by: Masayoshi MIZUMA
    Cc: Jan Beulich
    Cc: Frederic Weisbecker
    Cc: Linus Torvalds
    Signed-off-by: Ingo Molnar

    Seiichi Ikarashi