1. 28 4月, 2016 6 次提交
  2. 23 4月, 2016 1 次提交
  3. 01 4月, 2016 1 次提交
    • A
      efi/arm64: Don't apply MEMBLOCK_NOMAP to UEFI memory map mapping · 7cc8cbcf
      Ard Biesheuvel 提交于
      Commit 4dffbfc4 ("arm64/efi: mark UEFI reserved regions as
      MEMBLOCK_NOMAP") updated the mapping logic of both the RuntimeServices
      regions as well as the kernel's copy of the UEFI memory map to set the
      MEMBLOCK_NOMAP flag, which causes these regions to be omitted from the
      kernel direct mapping, and from being covered by a struct page.
      For the RuntimeServices regions, this is an obvious win, since the contents
      of these regions have significance to the firmware executable code itself,
      and are mapped in the EFI page tables using attributes that are described in
      the UEFI memory map, and which may differ from the attributes we use for
      mapping system RAM. It also prevents the contents from being modified
      inadvertently, since the EFI page tables are only live during runtime
      service invocations.
      
      None of these concerns apply to the allocation that covers the UEFI memory
      map, since it is entirely owned by the kernel. Setting the MEMBLOCK_NOMAP on
      the region did allow us to use ioremap_cache() to map it both on arm64 and
      on ARM, since the latter does not allow ioremap_cache() to be used on
      regions that are covered by a struct page.
      
      The ioremap_cache() on ARM restriction will be lifted in the v4.7 timeframe,
      but in the mean time, it has been reported that commit 4dffbfc4 causes
      a regression on 64k granule kernels. This is due to the fact that, given
      the 64 KB page size, the region that we end up removing from the kernel
      direct mapping is rounded up to 64 KB, and this 64 KB page frame may be
      shared with the initrd when booting via GRUB (which does not align its
      EFI_LOADER_DATA allocations to 64 KB like the stub does). This will crash
      the kernel as soon as it tries to access the initrd.
      
      Since the issue is specific to arm64, revert back to memblock_reserve()'ing
      the UEFI memory map when running on arm64. This is a temporary fix for v4.5
      and v4.6, and will be superseded in the v4.7 timeframe when we will be able
      to move back to memblock_reserve() unconditionally.
      
      Fixes: 4dffbfc4 ("arm64/efi: mark UEFI reserved regions as MEMBLOCK_NOMAP")
      Reported-by: NMark Salter <msalter@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Jeremy Linton <jeremy.linton@arm.com>
      Cc: Mark Langsdorf <mlangsdo@redhat.com>
      Cc: <stable@vger.kernel.org> # v4.5
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      7cc8cbcf
  4. 23 3月, 2016 2 次提交
    • D
      kernel: add kcov code coverage · 5c9a8750
      Dmitry Vyukov 提交于
      kcov provides code coverage collection for coverage-guided fuzzing
      (randomized testing).  Coverage-guided fuzzing is a testing technique
      that uses coverage feedback to determine new interesting inputs to a
      system.  A notable user-space example is AFL
      (http://lcamtuf.coredump.cx/afl/).  However, this technique is not
      widely used for kernel testing due to missing compiler and kernel
      support.
      
      kcov does not aim to collect as much coverage as possible.  It aims to
      collect more or less stable coverage that is function of syscall inputs.
      To achieve this goal it does not collect coverage in soft/hard
      interrupts and instrumentation of some inherently non-deterministic or
      non-interesting parts of kernel is disbled (e.g.  scheduler, locking).
      
      Currently there is a single coverage collection mode (tracing), but the
      API anticipates additional collection modes.  Initially I also
      implemented a second mode which exposes coverage in a fixed-size hash
      table of counters (what Quentin used in his original patch).  I've
      dropped the second mode for simplicity.
      
      This patch adds the necessary support on kernel side.  The complimentary
      compiler support was added in gcc revision 231296.
      
      We've used this support to build syzkaller system call fuzzer, which has
      found 90 kernel bugs in just 2 months:
      
        https://github.com/google/syzkaller/wiki/Found-Bugs
      
      We've also found 30+ bugs in our internal systems with syzkaller.
      Another (yet unexplored) direction where kcov coverage would greatly
      help is more traditional "blob mutation".  For example, mounting a
      random blob as a filesystem, or receiving a random blob over wire.
      
      Why not gcov.  Typical fuzzing loop looks as follows: (1) reset
      coverage, (2) execute a bit of code, (3) collect coverage, repeat.  A
      typical coverage can be just a dozen of basic blocks (e.g.  an invalid
      input).  In such context gcov becomes prohibitively expensive as
      reset/collect coverage steps depend on total number of basic
      blocks/edges in program (in case of kernel it is about 2M).  Cost of
      kcov depends only on number of executed basic blocks/edges.  On top of
      that, kernel requires per-thread coverage because there are always
      background threads and unrelated processes that also produce coverage.
      With inlined gcov instrumentation per-thread coverage is not possible.
      
      kcov exposes kernel PCs and control flow to user-space which is
      insecure.  But debugfs should not be mapped as user accessible.
      
      Based on a patch by Quentin Casasnovas.
      
      [akpm@linux-foundation.org: make task_struct.kcov_mode have type `enum kcov_mode']
      [akpm@linux-foundation.org: unbreak allmodconfig]
      [akpm@linux-foundation.org: follow x86 Makefile layout standards]
      Signed-off-by: NDmitry Vyukov <dvyukov@google.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Cc: syzkaller <syzkaller@googlegroups.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Tavis Ormandy <taviso@google.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Kees Cook <keescook@google.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: David Drysdale <drysdale@google.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Kirill A. Shutemov <kirill@shutemov.name>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5c9a8750
    • A
      drivers/firmware/efi/efivars.c: use in_compat_syscall() to check for compat callers · 4f01ed22
      Andy Lutomirski 提交于
      This should make no difference on any architecture, as x86's historical
      is_compat_task behavior really did check whether the calling syscall was
      a compat syscall.  x86's is_compat_task is going away, though.
      Signed-off-by: NAndy Lutomirski <luto@kernel.org>
      Reviewed-by: NMatt Fleming <matt@codeblueprint.co.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4f01ed22
  5. 29 2月, 2016 1 次提交
    • J
      objtool: Mark non-standard object files and directories · c0dd6716
      Josh Poimboeuf 提交于
      Code which runs outside the kernel's normal mode of operation often does
      unusual things which can cause a static analysis tool like objtool to
      emit false positive warnings:
      
       - boot image
       - vdso image
       - relocation
       - realmode
       - efi
       - head
       - purgatory
       - modpost
      
      Set OBJECT_FILES_NON_STANDARD for their related files and directories,
      which will tell objtool to skip checking them.  It's ok to skip them
      because they don't affect runtime stack traces.
      
      Also skip the following code which does the right thing with respect to
      frame pointers, but is too "special" to be validated by a tool:
      
       - entry
       - mcount
      
      Also skip the test_nx module because it modifies its exception handling
      table at runtime, which objtool can't understand.  Fortunately it's
      just a test module so it doesn't matter much.
      
      Currently objtool is the only user of OBJECT_FILES_NON_STANDARD, but it
      might eventually be useful for other tools.
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Chris J Arges <chris.j.arges@canonical.com>
      Cc: Jiri Slaby <jslaby@suse.cz>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michal Marek <mmarek@suse.cz>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Pedro Alves <palves@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: live-patching@vger.kernel.org
      Link: http://lkml.kernel.org/r/366c080e3844e8a5b6a0327dc7e8c2b90ca3baeb.1456719558.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      c0dd6716
  6. 24 2月, 2016 4 次提交
  7. 22 2月, 2016 7 次提交
  8. 16 2月, 2016 1 次提交
    • M
      efi: Add pstore variables to the deletion whitelist · e246eb56
      Matt Fleming 提交于
      Laszlo explains why this is a good idea,
      
       'This is because the pstore filesystem can be backed by UEFI variables,
        and (for example) a crash might dump the last kilobytes of the dmesg
        into a number of pstore entries, each entry backed by a separate UEFI
        variable in the above GUID namespace, and with a variable name
        according to the above pattern.
      
        Please see "drivers/firmware/efi/efi-pstore.c".
      
        While this patch series will not prevent the user from deleting those
        UEFI variables via the pstore filesystem (i.e., deleting a pstore fs
        entry will continue to delete the backing UEFI variable), I think it
        would be nice to preserve the possibility for the sysadmin to delete
        Linux-created UEFI variables that carry portions of the crash log,
        *without* having to mount the pstore filesystem.'
      
      There's also no chance of causing machines to become bricked by
      deleting these variables, which is the whole purpose of excluding
      things from the whitelist.
      
      Use the LINUX_EFI_CRASH_GUID guid and a wildcard '*' for the match so
      that we don't have to update the string in the future if new variable
      name formats are created for crash dump variables.
      Reported-by: NLaszlo Ersek <lersek@redhat.com>
      Acked-by: NPeter Jones <pjones@redhat.com>
      Tested-by: NPeter Jones <pjones@redhat.com>
      Cc: Matthew Garrett <mjg59@srcf.ucam.org>
      Cc: "Lee, Chun-Yi" <jlee@suse.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      e246eb56
  9. 11 2月, 2016 2 次提交
  10. 10 2月, 2016 2 次提交
  11. 03 2月, 2016 8 次提交
  12. 21 1月, 2016 1 次提交
  13. 14 1月, 2016 1 次提交
  14. 06 1月, 2016 1 次提交
  15. 14 12月, 2015 2 次提交
    • S
      x86/efi-bgrt: Fix kernel panic when mapping BGRT data · 50a0cb56
      Sai Praneeth 提交于
      Starting with this commit 35eb8b81edd4 ("x86/efi: Build our own page
      table structures") efi regions have a separate page directory called
      "efi_pgd". In order to access any efi region we have to first shift %cr3
      to this page table. In the bgrt code we are trying to copy bgrt_header
      and image, but these regions fall under "EFI_BOOT_SERVICES_DATA"
      and to access these regions we have to shift %cr3 to efi_pgd and not
      doing so will cause page fault as shown below.
      
      [    0.251599] Last level dTLB entries: 4KB 64, 2MB 0, 4MB 0, 1GB 4
      [    0.259126] Freeing SMP alternatives memory: 32K (ffffffff8230e000 - ffffffff82316000)
      [    0.271803] BUG: unable to handle kernel paging request at fffffffefce35002
      [    0.279740] IP: [<ffffffff821bca49>] efi_bgrt_init+0x144/0x1fd
      [    0.286383] PGD 300f067 PUD 0
      [    0.289879] Oops: 0000 [#1] SMP
      [    0.293566] Modules linked in:
      [    0.297039] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.0-rc1-eywa-eywa-built-in-47041+ #2
      [    0.306619] Hardware name: Intel Corporation Skylake Client platform/Skylake Y LPDDR3 RVP3, BIOS SKLSE2R1.R00.B104.B01.1511110114 11/11/2015
      [    0.320925] task: ffffffff820134c0 ti: ffffffff82000000 task.ti: ffffffff82000000
      [    0.329420] RIP: 0010:[<ffffffff821bca49>]  [<ffffffff821bca49>] efi_bgrt_init+0x144/0x1fd
      [    0.338821] RSP: 0000:ffffffff82003f18  EFLAGS: 00010246
      [    0.344852] RAX: fffffffefce35000 RBX: fffffffefce35000 RCX: fffffffefce2b000
      [    0.352952] RDX: 000000008a82b000 RSI: ffffffff8235bb80 RDI: 000000008a835000
      [    0.361050] RBP: ffffffff82003f30 R08: 000000008a865000 R09: ffffffffff202850
      [    0.369149] R10: ffffffff811ad62f R11: 0000000000000000 R12: 0000000000000000
      [    0.377248] R13: ffff88016dbaea40 R14: ffffffff822622c0 R15: ffffffff82003fb0
      [    0.385348] FS:  0000000000000000(0000) GS:ffff88016d800000(0000) knlGS:0000000000000000
      [    0.394533] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    0.401054] CR2: fffffffefce35002 CR3: 000000000300c000 CR4: 00000000003406f0
      [    0.409153] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    0.417252] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    0.425350] Stack:
      [    0.427638]  ffffffffffffffff ffffffff82256900 ffff88016dbaea40 ffffffff82003f40
      [    0.436086]  ffffffff821bbce0 ffffffff82003f88 ffffffff8219c0c2 0000000000000000
      [    0.444533]  ffffffff8219ba4a ffffffff822622c0 0000000000083000 00000000ffffffff
      [    0.452978] Call Trace:
      [    0.455763]  [<ffffffff821bbce0>] efi_late_init+0x9/0xb
      [    0.461697]  [<ffffffff8219c0c2>] start_kernel+0x463/0x47f
      [    0.467928]  [<ffffffff8219ba4a>] ? set_init_arg+0x55/0x55
      [    0.474159]  [<ffffffff8219b120>] ? early_idt_handler_array+0x120/0x120
      [    0.481669]  [<ffffffff8219b5ee>] x86_64_start_reservations+0x2a/0x2c
      [    0.488982]  [<ffffffff8219b72d>] x86_64_start_kernel+0x13d/0x14c
      [    0.495897] Code: 00 41 b4 01 48 8b 78 28 e8 09 36 01 00 48 85 c0 48 89 c3 75 13 48 c7 c7 f8 ac d3 81 31 c0 e8 d7 3b fb fe e9 b5 00 00 00 45 84 e4 <44> 8b 6b 02 74 0d be 06 00 00 00 48 89 df e8 ae 34 0$
      [    0.518151] RIP  [<ffffffff821bca49>] efi_bgrt_init+0x144/0x1fd
      [    0.524888]  RSP <ffffffff82003f18>
      [    0.528851] CR2: fffffffefce35002
      [    0.532615] ---[ end trace 7b06521e6ebf2aea ]---
      [    0.537852] Kernel panic - not syncing: Attempted to kill the idle task!
      
      As said above one way to fix this bug is to shift %cr3 to efi_pgd but we
      are not doing that way because it leaks inner details of how we switch
      to EFI page tables into a new call site and it also adds duplicate code.
      Instead, we remove the call to efi_lookup_mapped_addr() and always
      perform early_mem*() instead of early_io*() because we want to remap RAM
      regions and not I/O regions. We also delete efi_lookup_mapped_addr()
      because we are no longer using it.
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Reported-by: NWendy Wang <wendy.wang@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Ricardo Neri <ricardo.neri@intel.com>
      Cc: Ravi Shankar <ravi.v.shankar@intel.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      50a0cb56
    • R
      efi/esrt: Don't preformat name · 7f83773c
      Rasmus Villemoes 提交于
      kobject_init_and_add takes a format string+args, so there's no reason
      to do this formatting in advance.
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Peter Jones <pjones@redhat.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      7f83773c