1. 24 5月, 2016 1 次提交
  2. 20 4月, 2016 1 次提交
  3. 13 4月, 2016 1 次提交
    • A
      x86/vdso: Remove direct HPET access through the vDSO · 1ed95e52
      Andy Lutomirski 提交于
      Allowing user code to map the HPET is problematic.  HPET
      implementations are notoriously buggy, and there are probably many
      machines on which even MMIO reads from bogus HPET addresses are
      problematic.
      
      We have a report that the Dell Precision M2800 with:
      
        ACPI: HPET 0x00000000C8FE6238 000038 (v01 DELL   CBX3  01072009 AMI. 00000005)
      
      is either so slow when accessing the HPET or actually hangs in some
      regard, causing soft lockups to be reported if users do unexpected
      things to the HPET.
      
      The vclock HPET code has also always been a questionable speedup.
      Accessing an HPET is exceedingly slow (on the order of several
      microseconds), so the added overhead in requiring a syscall to read
      the HPET is a small fraction of the total code of accessing it.
      
      To avoid future problems, let's just delete the code entirely.
      
      In the long run, this could actually be a speedup.  Waiman Long as a
      patch to optimize the case where multiple CPUs contend for the HPET,
      but that won't help unless all the accesses are mediated by the
      kernel.
      Reported-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: NAndy Lutomirski <luto@kernel.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <Waiman.Long@hpe.com>
      Cc: Waiman Long <waiman.long@hpe.com>
      Link: http://lkml.kernel.org/r/d2f90bba98db9905041cff294646d290d378f67a.1460074438.git.luto@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1ed95e52
  4. 23 3月, 2016 1 次提交
    • 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
  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 1 次提交
  7. 22 2月, 2016 1 次提交
    • K
      x86/vdso: Mark the vDSO code read-only after init · 018ef8dc
      Kees Cook 提交于
      The vDSO does not need to be writable after __init, so mark it as
      __ro_after_init. The result kills the exploit method of writing to the
      vDSO from kernel space resulting in userspace executing the modified code,
      as shown here to bypass SMEP restrictions: http://itszn.com/blog/?p=21
      
      The memory map (with added vDSO address reporting) shows the vDSO moving
      into read-only memory:
      
      Before:
      	[    0.143067] vDSO @ ffffffff82004000
      	[    0.143551] vDSO @ ffffffff82006000
      	---[ High Kernel Mapping ]---
      	0xffffffff80000000-0xffffffff81000000      16M                         pmd
      	0xffffffff81000000-0xffffffff81800000       8M   ro     PSE     GLB x  pmd
      	0xffffffff81800000-0xffffffff819f3000    1996K   ro             GLB x  pte
      	0xffffffff819f3000-0xffffffff81a00000      52K   ro                 NX pte
      	0xffffffff81a00000-0xffffffff81e00000       4M   ro     PSE     GLB NX pmd
      	0xffffffff81e00000-0xffffffff81e05000      20K   ro             GLB NX pte
      	0xffffffff81e05000-0xffffffff82000000    2028K   ro                 NX pte
      	0xffffffff82000000-0xffffffff8214f000    1340K   RW             GLB NX pte
      	0xffffffff8214f000-0xffffffff82281000    1224K   RW                 NX pte
      	0xffffffff82281000-0xffffffff82400000    1532K   RW             GLB NX pte
      	0xffffffff82400000-0xffffffff83200000      14M   RW     PSE     GLB NX pmd
      	0xffffffff83200000-0xffffffffc0000000     974M                         pmd
      
      After:
      	[    0.145062] vDSO @ ffffffff81da1000
      	[    0.146057] vDSO @ ffffffff81da4000
      	---[ High Kernel Mapping ]---
      	0xffffffff80000000-0xffffffff81000000      16M                         pmd
      	0xffffffff81000000-0xffffffff81800000       8M   ro     PSE     GLB x  pmd
      	0xffffffff81800000-0xffffffff819f3000    1996K   ro             GLB x  pte
      	0xffffffff819f3000-0xffffffff81a00000      52K   ro                 NX pte
      	0xffffffff81a00000-0xffffffff81e00000       4M   ro     PSE     GLB NX pmd
      	0xffffffff81e00000-0xffffffff81e0b000      44K   ro             GLB NX pte
      	0xffffffff81e0b000-0xffffffff82000000    2004K   ro                 NX pte
      	0xffffffff82000000-0xffffffff8214c000    1328K   RW             GLB NX pte
      	0xffffffff8214c000-0xffffffff8227e000    1224K   RW                 NX pte
      	0xffffffff8227e000-0xffffffff82400000    1544K   RW             GLB NX pte
      	0xffffffff82400000-0xffffffff83200000      14M   RW     PSE     GLB NX pmd
      	0xffffffff83200000-0xffffffffc0000000     974M                         pmd
      
      Based on work by PaX Team and Brad Spengler.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      Acked-by: NH. Peter Anvin <hpa@linux.intel.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brad Spengler <spender@grsecurity.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: David Brown <david.brown@linaro.org>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Emese Revfy <re.emese@gmail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Mathias Krause <minipli@googlemail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: PaX Team <pageexec@freemail.hu>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: kernel-hardening@lists.openwall.com
      Cc: linux-arch <linux-arch@vger.kernel.org>
      Link: http://lkml.kernel.org/r/1455748879-21872-7-git-send-email-keescook@chromium.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      018ef8dc
  8. 30 1月, 2016 2 次提交
  9. 21 1月, 2016 1 次提交
  10. 13 1月, 2016 1 次提交
  11. 12 1月, 2016 4 次提交
  12. 21 12月, 2015 2 次提交
  13. 11 12月, 2015 4 次提交
  14. 09 10月, 2015 5 次提交
  15. 07 10月, 2015 1 次提交
  16. 23 9月, 2015 1 次提交
    • T
      x86/vdso32: Define PGTABLE_LEVELS to 32bit VDSO · fb535ccb
      Toshi Kani 提交于
      In case of CONFIG_X86_64, vdso32/vclock_gettime.c fakes a 32-bit
      non-PAE kernel configuration by re-defining it to CONFIG_X86_32.
      However, it does not re-define CONFIG_PGTABLE_LEVELS leaving it
      as 4 levels.
      
      This mismatch leads <asm/pgtable_type.h> to NOT include <asm-generic/
      pgtable-nopud.h> and <asm-generic/pgtable-nopmd.h>, which will cause
      compile errors when a later patch enhances <asm/pgtable_type.h> to
      use PUD_SHIFT and PMD_SHIFT.  These -nopud & -nopmd headers define
      these SHIFTs for the 32-bit non-PAE kernel.
      
      Fix it by re-defining CONFIG_PGTABLE_LEVELS to 2 levels.
      Signed-off-by: NToshi Kani <toshi.kani@hpe.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Konrad Wilk <konrad.wilk@oracle.com>
      Cc: Robert Elliot <elliott@hpe.com>
      Cc: linux-mm@kvack.org
      Link: http://lkml.kernel.org/r/1442514264-12475-2-git-send-email-toshi.kani@hpe.comSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      fb535ccb
  17. 08 8月, 2015 1 次提交
    • A
      x86/vdso: Emit a GNU hash · 6b7e2654
      Andy Lutomirski 提交于
      Some dynamic loaders may be slightly faster if a GNU hash is
      available.  Strangely, this seems to have no effect at all on
      the vdso size.
      
      This is unlikely to have any measurable effect on the time it
      takes to resolve vdso symbols (since there are so few of them).
      In some contexts, it can be a win for a different reason: if
      every DSO has a GNU hash section, then libc can avoid
      calculating SysV hashes at all.  Both musl and glibc appear to
      have this optimization.
      
      It's plausible that this breaks some ancient glibc version.  If
      so, then, depending on what glibc versions break, we could
      either require COMPAT_VDSO for them or consider reverting.
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Isaac Dunham <ibid.ag@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nathan Lynch <nathan_lynch@mentor.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: musl@lists.openwall.com <musl@lists.openwall.com>
      Link: http://lkml.kernel.org/r/fd56cc057a2d62ab31c56a48d04fccb435b3fd4f.1438897382.git.luto@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6b7e2654
  18. 06 7月, 2015 4 次提交
  19. 04 6月, 2015 1 次提交
    • I
      x86/asm/entry, x86/vdso: Move the vDSO code to arch/x86/entry/vdso/ · d603c8e1
      Ingo Molnar 提交于
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d603c8e1