1. 02 7月, 2019 3 次提交
  2. 28 6月, 2019 2 次提交
  3. 27 6月, 2019 3 次提交
  4. 26 6月, 2019 5 次提交
    • A
      x86/speculation: Allow guests to use SSBD even if host does not · c1f7fec1
      Alejandro Jimenez 提交于
      The bits set in x86_spec_ctrl_mask are used to calculate the guest's value
      of SPEC_CTRL that is written to the MSR before VMENTRY, and control which
      mitigations the guest can enable.  In the case of SSBD, unless the host has
      enabled SSBD always on mode (by passing "spec_store_bypass_disable=on" in
      the kernel parameters), the SSBD bit is not set in the mask and the guest
      can not properly enable the SSBD always on mitigation mode.
      
      This has been confirmed by running the SSBD PoC on a guest using the SSBD
      always on mitigation mode (booted with kernel parameter
      "spec_store_bypass_disable=on"), and verifying that the guest is vulnerable
      unless the host is also using SSBD always on mode. In addition, the guest
      OS incorrectly reports the SSB vulnerability as mitigated.
      
      Always set the SSBD bit in x86_spec_ctrl_mask when the host CPU supports
      it, allowing the guest to use SSBD whether or not the host has chosen to
      enable the mitigation in any of its modes.
      
      Fixes: be6fcb54 ("x86/bugs: Rework spec_ctrl base and mask logic")
      Signed-off-by: NAlejandro Jimenez <alejandro.j.jimenez@oracle.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NLiam Merwick <liam.merwick@oracle.com>
      Reviewed-by: NMark Kanda <mark.kanda@oracle.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Cc: bp@alien8.de
      Cc: rkrcmar@redhat.com
      Cc: kvm@vger.kernel.org
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1560187210-11054-1-git-send-email-alejandro.j.jimenez@oracle.com
      c1f7fec1
    • G
      csky: Fixup libgcc unwind error · 19e5e2ae
      Guo Ren 提交于
      The struct rt_sigframe is also defined in libgcc/config/csky/linux-unwind.h
      of gcc. Although there is no use for the first three word space, we must
      keep them the same with linux-unwind.h for member position.
      
      The BUG is found in glibc test with the tst-cancel02.
      The BUG is from commit:bf241682 of linux-5.2-rc1 merge window.
      Signed-off-by: NGuo Ren <ren_guo@c-sky.com>
      Signed-off-by: NMao Han <han_mao@c-sky.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      19e5e2ae
    • K
      x86/mm: Handle physical-virtual alignment mismatch in phys_p4d_init() · 432c8332
      Kirill A. Shutemov 提交于
      Kyle has reported occasional crashes when booting a kernel in 5-level
      paging mode with KASLR enabled:
      
        WARNING: CPU: 0 PID: 0 at arch/x86/mm/init_64.c:87 phys_p4d_init+0x1d4/0x1ea
        RIP: 0010:phys_p4d_init+0x1d4/0x1ea
        Call Trace:
         __kernel_physical_mapping_init+0x10a/0x35c
         kernel_physical_mapping_init+0xe/0x10
         init_memory_mapping+0x1aa/0x3b0
         init_range_memory_mapping+0xc8/0x116
         init_mem_mapping+0x225/0x2eb
         setup_arch+0x6ff/0xcf5
         start_kernel+0x64/0x53b
         ? copy_bootdata+0x1f/0xce
         x86_64_start_reservations+0x24/0x26
         x86_64_start_kernel+0x8a/0x8d
         secondary_startup_64+0xb6/0xc0
      
      which causes later:
      
        BUG: unable to handle page fault for address: ff484d019580eff8
        #PF: supervisor read access in kernel mode
        #PF: error_code(0x0000) - not-present page
        BAD
        Oops: 0000 [#1] SMP NOPTI
        RIP: 0010:fill_pud+0x13/0x130
        Call Trace:
         set_pte_vaddr_p4d+0x2e/0x50
         set_pte_vaddr+0x6f/0xb0
         __native_set_fixmap+0x28/0x40
         native_set_fixmap+0x39/0x70
         register_lapic_address+0x49/0xb6
         early_acpi_boot_init+0xa5/0xde
         setup_arch+0x944/0xcf5
         start_kernel+0x64/0x53b
      
      Kyle bisected the issue to commit b569c184 ("x86/mm/KASLR: Reduce
      randomization granularity for 5-level paging to 1GB")
      
      Before this commit PAGE_OFFSET was always aligned to P4D_SIZE when booting
      5-level paging mode. But now only PUD_SIZE alignment is guaranteed.
      
      In the case I was able to reproduce the following vaddr/paddr values were
      observed in phys_p4d_init():
      
      Iteration     vaddr			paddr
         1 	      0xff4228027fe00000 	0x033fe00000
         2	      0xff42287f40000000	0x8000000000
      
      'vaddr' in both cases belongs to the same p4d entry.
      
      But due to the original assumption that PAGE_OFFSET is aligned to P4D_SIZE
      this overlap cannot be handled correctly. The code assumes strictly aligned
      entries and unconditionally increments the index into the P4D table, which
      creates false duplicate entries. Once the index reaches the end, the last
      entry in the page table is missing.
      
      Aside of that the 'paddr >= paddr_end' condition can evaluate wrong which
      causes an P4D entry to be cleared incorrectly.
      
      Change the loop in phys_p4d_init() to walk purely based on virtual
      addresses like __kernel_physical_mapping_init() does. This makes it work
      correctly with unaligned virtual addresses.
      
      Fixes: b569c184 ("x86/mm/KASLR: Reduce randomization granularity for 5-level paging to 1GB")
      Reported-by: NKyle Pelton <kyle.d.pelton@intel.com>
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Tested-by: NKyle Pelton <kyle.d.pelton@intel.com>
      Acked-by: NBaoquan He <bhe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20190624123150.920-1-kirill.shutemov@linux.intel.com
      432c8332
    • K
      x86/boot/64: Add missing fixup_pointer() for next_early_pgt access · c1887159
      Kirill A. Shutemov 提交于
      __startup_64() uses fixup_pointer() to access global variables in a
      position-independent fashion. Access to next_early_pgt was wrapped into the
      helper, but one instance in the 5-level paging branch was missed.
      
      GCC generates a R_X86_64_PC32 PC-relative relocation for the access which
      doesn't trigger the issue, but Clang emmits a R_X86_64_32S which leads to
      an invalid memory access and system reboot.
      
      Fixes: 187e91fe ("x86/boot/64/clang: Use fixup_pointer() to access 'next_early_pgt'")
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Alexander Potapenko <glider@google.com>
      Link: https://lkml.kernel.org/r/20190620112422.29264-1-kirill.shutemov@linux.intel.com
      c1887159
    • K
      x86/boot/64: Fix crash if kernel image crosses page table boundary · 81c7ed29
      Kirill A. Shutemov 提交于
      A kernel which boots in 5-level paging mode crashes in a small percentage
      of cases if KASLR is enabled.
      
      This issue was tracked down to the case when the kernel image unpacks in a
      way that it crosses an 1G boundary. The crash is caused by an overrun of
      the PMD page table in __startup_64() and corruption of P4D page table
      allocated next to it. This particular issue is not visible with 4-level
      paging as P4D page tables are not used.
      
      But the P4D and the PUD calculation have similar problems.
      
      The PMD index calculation is wrong due to operator precedence, which fails
      to confine the PMDs in the PMD array on wrap around.
      
      The P4D calculation for 5-level paging and the PUD calculation calculate
      the first index correctly, but then blindly increment it which causes the
      same issue when a kernel image is located across a 512G and for 5-level
      paging across a 46T boundary.
      
      This wrap around mishandling was introduced when these parts moved from
      assembly to C.
      
      Restore it to the correct behaviour.
      
      Fixes: c88d7150 ("x86/boot/64: Rewrite startup_64() in C")
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20190620112345.28833-1-kirill.shutemov@linux.intel.com
      81c7ed29
  5. 25 6月, 2019 5 次提交
  6. 24 6月, 2019 1 次提交
  7. 22 6月, 2019 2 次提交
  8. 21 6月, 2019 3 次提交
  9. 20 6月, 2019 2 次提交
    • R
      x86/resctrl: Prevent possible overrun during bitmap operations · 32f010de
      Reinette Chatre 提交于
      While the DOC at the beginning of lib/bitmap.c explicitly states that
      "The number of valid bits in a given bitmap does _not_ need to be an
      exact multiple of BITS_PER_LONG.", some of the bitmap operations do
      indeed access BITS_PER_LONG portions of the provided bitmap no matter
      the size of the provided bitmap.
      
      For example, if find_first_bit() is provided with an 8 bit bitmap the
      operation will access BITS_PER_LONG bits from the provided bitmap. While
      the operation ensures that these extra bits do not affect the result,
      the memory is still accessed.
      
      The capacity bitmasks (CBMs) are typically stored in u32 since they
      can never exceed 32 bits. A few instances exist where a bitmap_*
      operation is performed on a CBM by simply pointing the bitmap operation
      to the stored u32 value.
      
      The consequence of this pattern is that some bitmap_* operations will
      access out-of-bounds memory when interacting with the provided CBM.
      
      This same issue has previously been addressed with commit 49e00eee
      ("x86/intel_rdt: Fix out-of-bounds memory access in CBM tests")
      but at that time not all instances of the issue were fixed.
      
      Fix this by using an unsigned long to store the capacity bitmask data
      that is passed to bitmap functions.
      
      Fixes: e6519011 ("x86/intel_rdt: Introduce "bit_usage" to display cache allocations details")
      Fixes: f4e80d67 ("x86/intel_rdt: Resctrl files reflect pseudo-locked information")
      Fixes: 95f0b77e ("x86/intel_rdt: Initialize new resource group with sane defaults")
      Signed-off-by: NReinette Chatre <reinette.chatre@intel.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/58c9b6081fd9bf599af0dfc01a6fdd335768efef.1560975645.git.reinette.chatre@intel.com
      32f010de
    • S
      KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries · 50087112
      Suraj Jitindar Singh 提交于
      When a guest vcpu moves from one physical thread to another it is
      necessary for the host to perform a tlb flush on the previous core if
      another vcpu from the same guest is going to run there. This is because the
      guest may use the local form of the tlb invalidation instruction meaning
      stale tlb entries would persist where it previously ran. This is handled
      on guest entry in kvmppc_check_need_tlb_flush() which calls
      flush_guest_tlb() to perform the tlb flush.
      
      Previously the generic radix__local_flush_tlb_lpid_guest() function was
      used, however the functionality was reimplemented in flush_guest_tlb()
      to avoid the trace_tlbie() call as the flushing may be done in real
      mode. The reimplementation in flush_guest_tlb() was missing an erat
      invalidation after flushing the tlb.
      
      This lead to observable memory corruption in the guest due to the
      caching of stale translations. Fix this by adding the erat invalidation.
      
      Fixes: 70ea13f6 ("KVM: PPC: Book3S HV: Flush TLB on secondary radix threads")
      Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      50087112
  10. 19 6月, 2019 14 次提交