25 Apr, 2016

1 commit


24 Apr, 2016

1 commit


22 Apr, 2016

1 commit

  • When doing a make allmodconfig, I hit the following compile error:

    In file included from builtin-check.c:32:0:
    elf.h:22:18: fatal error: gelf.h: No such file or directory
    compilation terminated.
    ...

    Digging into it, it appears that the $(shell ..) command in the Makefile does
    not give the proper result when it fails to find -lelf, and continues to
    compile objtool.

    Instead, use the "try-run" makefile macro to perform the test. This gives a
    proper result for both cases.

    Signed-off-by: Steven Rostedt
    Acked-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Fixes: 442f04c34a1a4 ("objtool: Add tool to perform compile-time stack metadata validation")
    Link: http://lkml.kernel.org/r/20160420153234.GA24032@home.goodmis.org
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

18 Apr, 2016

1 commit


11 Apr, 2016

1 commit


03 Apr, 2016

1 commit


27 Mar, 2016

1 commit


25 Mar, 2016

1 commit

  • Pull kbuild updates from Michal Marek:

    - make dtbs_install fix

    - Error handling fix fixdep and link-vmlinux.sh

    - __UNIQUE_ID fix for clang

    - Fix for if_changed_* to suppress the "is up to date." message

    - The kernel is built with -Werror=incompatible-pointer-types

    * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
    kbuild: Add option to turn incompatible pointer check into error
    kbuild: suppress annoying "... is up to date." message
    kbuild: fixdep: Check fstat(2) return value
    scripts/link-vmlinux.sh: force error on kallsyms failure
    Kbuild: provide a __UNIQUE_ID for clang
    dtbsinstall: don't move target directory out of the way

    Linus Torvalds
     

23 Mar, 2016

1 commit

  • 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: Dmitry Vyukov
    Reviewed-by: Kees Cook
    Cc: syzkaller
    Cc: Vegard Nossum
    Cc: Catalin Marinas
    Cc: Tavis Ormandy
    Cc: Will Deacon
    Cc: Quentin Casasnovas
    Cc: Kostya Serebryany
    Cc: Eric Dumazet
    Cc: Alexander Potapenko
    Cc: Kees Cook
    Cc: Bjorn Helgaas
    Cc: Sasha Levin
    Cc: David Drysdale
    Cc: Ard Biesheuvel
    Cc: Andrey Ryabinin
    Cc: Kirill A. Shutemov
    Cc: Jiri Slaby
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dmitry Vyukov
     

21 Mar, 2016

1 commit

  • Pull 'objtool' stack frame validation from Ingo Molnar:
    "This tree adds a new kernel build-time object file validation feature
    (ONFIG_STACK_VALIDATION=y): kernel stack frame correctness validation.
    It was written by and is maintained by Josh Poimboeuf.

    The motivation: there's a category of hard to find kernel bugs, most
    of them in assembly code (but also occasionally in C code), that
    degrades the quality of kernel stack dumps/backtraces. These bugs are
    hard to detect at the source code level. Such bugs result in
    incorrect/incomplete backtraces most of time - but can also in some
    rare cases result in crashes or other undefined behavior.

    The build time correctness checking is done via the new 'objtool'
    user-space utility that was written for this purpose and which is
    hosted in the kernel repository in tools/objtool/. The tool's (very
    simple) UI and source code design is shaped after Git and perf and
    shares quite a bit of infrastructure with tools/perf (which tooling
    infrastructure sharing effort got merged via perf and is already
    upstream). Objtool follows the well-known kernel coding style.

    Objtool does not try to check .c or .S files, it instead analyzes the
    resulting .o generated machine code from first principles: it decodes
    the instruction stream and interprets it. (Right now objtool supports
    the x86-64 architecture.)

    From tools/objtool/Documentation/stack-validation.txt:

    "The kernel CONFIG_STACK_VALIDATION option enables a host tool named
    objtool which runs at compile time. It has a "check" subcommand
    which analyzes every .o file and ensures the validity of its stack
    metadata. It enforces a set of rules on asm code and C inline
    assembly code so that stack traces can be reliable.

    Currently it only checks frame pointer usage, but there are plans to
    add CFI validation for C files and CFI generation for asm files.

    For each function, it recursively follows all possible code paths
    and validates the correct frame pointer state at each instruction.

    It also follows code paths involving special sections, like
    .altinstructions, __jump_table, and __ex_table, which can add
    alternative execution paths to a given instruction (or set of
    instructions). Similarly, it knows how to follow switch statements,
    for which gcc sometimes uses jump tables."

    When this new kernel option is enabled (it's disabled by default), the
    tool, if it finds any suspicious assembly code pattern, outputs
    warnings in compiler warning format:

    warning: objtool: rtlwifi_rate_mapping()+0x2e7: frame pointer state mismatch
    warning: objtool: cik_tiling_mode_table_init()+0x6ce: call without frame pointer save/setup
    warning: objtool:__schedule()+0x3c0: duplicate frame pointer save
    warning: objtool:__schedule()+0x3fd: sibling call from callable instruction with changed frame pointer

    ... so that scripts that pick up compiler warnings will notice them.
    All known warnings triggered by the tool are fixed by the tree, most
    of the commits in fact prepare the kernel to be warning-free. Most of
    them are bugfixes or cleanups that stand on their own, but there are
    also some annotations of 'special' stack frames for justified cases
    such entries to JIT-ed code (BPF) or really special boot time code.

    There are two other long-term motivations behind this tool as well:

    - To improve the quality and reliability of kernel stack frames, so
    that they can be used for optimized live patching.

    - To create independent infrastructure to check the correctness of
    CFI stack frames at build time. CFI debuginfo is notoriously
    unreliable and we cannot use it in the kernel as-is without extra
    checking done both on the kernel side and on the build side.

    The quality of kernel stack frames matters to debuggability as well,
    so IMO we can merge this without having to consider the live patching
    or CFI debuginfo angle"

    * 'core-objtool-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (52 commits)
    objtool: Only print one warning per function
    objtool: Add several performance improvements
    tools: Copy hashtable.h into tools directory
    objtool: Fix false positive warnings for functions with multiple switch statements
    objtool: Rename some variables and functions
    objtool: Remove superflous INIT_LIST_HEAD
    objtool: Add helper macros for traversing instructions
    objtool: Fix false positive warnings related to sibling calls
    objtool: Compile with debugging symbols
    objtool: Detect infinite recursion
    objtool: Prevent infinite recursion in noreturn detection
    objtool: Detect and warn if libelf is missing and don't break the build
    tools: Support relative directory path for 'O='
    objtool: Support CROSS_COMPILE
    x86/asm/decoder: Use explicitly signed chars
    objtool: Enable stack metadata validation on 64-bit x86
    objtool: Add CONFIG_STACK_VALIDATION option
    objtool: Add tool to perform compile-time stack metadata validation
    x86/kprobes: Mark kretprobe_trampoline() stack frame as non-standard
    sched: Always inline context_switch()
    ...

    Linus Torvalds
     

18 Mar, 2016

1 commit

  • …/git/shuah/linux-kselftest

    Pull Kselftest updates from Shuah Khan:
    "This update for Kselftest adds:

    - A new feature to create test-specific kconfig fragments. This
    feature helps configure Kselftests to test specific Kernel
    Configuration options as opposed to defconfig.

    - A new test for Media Controller API

    - A few fixes"

    * tag 'linux-kselftest-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
    selftests: media_dcevice_test fix usage information
    selftests: media_dcevice_test fix to handle ioctl failure case
    selftests: add missing .gitignore file or entry
    Makefile: add kselftest-merge
    selftests: create test-specific kconfig fragments
    selftests: breakpoint: add step_after_suspend_test
    selftests: add a new test for Media Controller API

    Linus Torvalds
     

16 Mar, 2016

1 commit

  • With the introduction of the simple wait API we have two very
    similar APIs in the kernel. For example wake_up() and swake_up()
    is only one character away. Although the compiler will warn
    happily the wrong usage it keeps on going an even links the kernel.
    Thomas and Peter would rather like to see early missuses reported
    as error early on.

    In a first attempt we tried to wrap all swait and wait calls
    into a macro which has an compile time type assertion. The result
    was pretty ugly and wasn't able to catch all wrong usages.
    woken_wake_function(), autoremove_wake_function() and wake_bit_function()
    are assigned as function pointers. Wrapping them with a macro around is
    not possible. Prefixing them with '_' was also not a real option
    because there some users in the kernel which do use them as well.
    All in all this attempt looked to intrusive and too ugly.

    An alternative is to turn the pointer type check into an error which
    catches wrong type uses. Obviously not only the swait/wait ones. That
    isn't a bad thing either.

    Signed-off-by: Daniel Wagner
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Thomas Gleixner
    Acked-by: Ingo Molnar
    Signed-off-by: Michal Marek

    Daniel Wagner
     

14 Mar, 2016

1 commit


07 Mar, 2016

1 commit


05 Mar, 2016

1 commit

  • With CONFIG_STACK_VALIDATION enabled, if the host system doesn't have
    a development version of libelf installed, the build fails with errors
    like:

    elf.h:22:18: fatal error: gelf.h: No such file or directory compilation terminated.

    Instead of failing to build, instead just print a warning and disable
    stack validation.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephen Rothwell
    Cc: Sudip Mukherjee
    Cc: Thomas Gleixner
    Cc: linux-next@vger.kernel.org
    Cc: linux@roeck-us.net
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/8c27fe00face60f42e888ddb3142c97e45223165.1457026550.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

03 Mar, 2016

1 commit

  • Running "make O=foo" (with a relative directory path) fails with:

    scripts/Makefile.include:3: *** O=foo does not exist. Stop.
    /home/jpoimboe/git/linux/Makefile:1547: recipe for target 'tools/objtool' failed

    The tools Makefile gets confused by the relative path and tries to build
    objtool in tools/foo. Convert the output directory to an absolute path
    before passing it to the tools Makefile.

    Reported-by: Sudip Mukherjee
    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Stephen Rothwell
    Cc: Thomas Gleixner
    Cc: linux-next@vger.kernel.org
    Cc: linux@roeck-us.net
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/94a078c6c998fac9f01a14f574008bf7dff40191.1457016803.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     

29 Feb, 2016

2 commits

  • Add a CONFIG_STACK_VALIDATION option which will run "objtool check" for
    each .o file to ensure the validity of its stack metadata.

    Signed-off-by: Josh Poimboeuf
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnaldo Carvalho de Melo
    Cc: Bernd Petrovitsch
    Cc: Borislav Petkov
    Cc: Chris J Arges
    Cc: Jiri Slaby
    Cc: Linus Torvalds
    Cc: Michal Marek
    Cc: Namhyung Kim
    Cc: Pedro Alves
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: live-patching@vger.kernel.org
    Link: http://lkml.kernel.org/r/92baab69a6bf9bc7043af0bfca9fb964a1d45546.1456719558.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar

    Josh Poimboeuf
     
  • Linus Torvalds
     

26 Feb, 2016

1 commit

  • Add kselftest-merge to enable the dependencies of kernel config
    for all the kselftest testcases. User should call it after create
    the kernel configuration(.config), eg:

    $ make kselftest-merge

    Signed-off-by: Bamvor Jian Zhang
    Signed-off-by: Shuah Khan

    Bamvor Jian Zhang
     

21 Feb, 2016

1 commit


15 Feb, 2016

1 commit


08 Feb, 2016

1 commit


01 Feb, 2016

1 commit


25 Jan, 2016

1 commit


21 Jan, 2016

2 commits

  • UBSAN uses compile-time instrumentation to catch undefined behavior
    (UB). Compiler inserts code that perform certain kinds of checks before
    operations that could cause UB. If check fails (i.e. UB detected)
    __ubsan_handle_* function called to print error message.

    So the most of the work is done by compiler. This patch just implements
    ubsan handlers printing errors.

    GCC has this capability since 4.9.x [1] (see -fsanitize=undefined
    option and its suboptions).
    However GCC 5.x has more checkers implemented [2].
    Article [3] has a bit more details about UBSAN in the GCC.

    [1] - https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Debugging-Options.html
    [2] - https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
    [3] - http://developerblog.redhat.com/2014/10/16/gcc-undefined-behavior-sanitizer-ubsan/

    Issues which UBSAN has found thus far are:

    Found bugs:

    * out-of-bounds access - 97840cb67ff5 ("netfilter: nfnetlink: fix
    insufficient validation in nfnetlink_bind")

    undefined shifts:

    * d48458d4a768 ("jbd2: use a better hash function for the revoke
    table")

    * 10632008b9e1 ("clockevents: Prevent shift out of bounds")

    * 'x << -1' shift in ext4 -
    http://lkml.kernel.org/r/

    * undefined rol32(0) -
    http://lkml.kernel.org/r/

    * undefined dirty_ratelimit calculation -
    http://lkml.kernel.org/r/

    * undefined roundown_pow_of_two(0) -
    http://lkml.kernel.org/r/

    * [WONTFIX] undefined shift in __bpf_prog_run -
    http://lkml.kernel.org/r/

    WONTFIX here because it should be fixed in bpf program, not in kernel.

    signed overflows:

    * 32a8df4e0b33f ("sched: Fix odd values in effective_load()
    calculations")

    * mul overflow in ntp -
    http://lkml.kernel.org/r/

    * incorrect conversion into rtc_time in rtc_time64_to_tm() -
    http://lkml.kernel.org/r/

    * unvalidated timespec in io_getevents() -
    http://lkml.kernel.org/r/

    * [NOTABUG] signed overflow in ktime_add_safe() -
    http://lkml.kernel.org/r/

    [akpm@linux-foundation.org: fix unused local warning]
    [akpm@linux-foundation.org: fix __int128 build woes]
    Signed-off-by: Andrey Ryabinin
    Cc: Peter Zijlstra
    Cc: Sasha Levin
    Cc: Randy Dunlap
    Cc: Rasmus Villemoes
    Cc: Jonathan Corbet
    Cc: Michal Marek
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Yury Gribov
    Cc: Dmitry Vyukov
    Cc: Konstantin Khlebnikov
    Cc: Kostya Serebryany
    Cc: Johannes Berg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Ryabinin
     
  • Pull kbuild updates from Michal Marek:
    - Make -m in makefiles work like -y and fix the
    fallout
    - Minor genksyms fix
    - Fix race with make -j install modules_install
    - Move -Wsign-compare from make W=1 to W=2
    - Other minor fixes

    * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
    kbuild: Demote 'sign-compare' warning to W=2
    Makefile: revert "Makefile: Document ability to make file.lst and file.S" partially
    kbuild: Do not run modules_install and install in paralel
    genksyms: Handle string literals with spaces in reference files
    fixdep: constify strrcmp arguments
    ath10k: Fix build with CONFIG_THERMAL=m
    Revert "drm: Hack around CONFIG_AGP=m build failures"
    kbuild: Allow to specify composite modules with modname-m
    staging/ad7606: Actually build the interface modules

    Linus Torvalds
     

11 Jan, 2016

1 commit


04 Jan, 2016

1 commit


28 Dec, 2015

1 commit


21 Dec, 2015

1 commit


17 Dec, 2015

1 commit


14 Dec, 2015

1 commit


10 Dec, 2015

1 commit


07 Dec, 2015

1 commit


30 Nov, 2015

1 commit


23 Nov, 2015

1 commit


16 Nov, 2015

1 commit


11 Nov, 2015

1 commit


06 Nov, 2015

2 commits

  • Pull KVM updates from Paolo Bonzini:
    "First batch of KVM changes for 4.4.

    s390:
    A bunch of fixes and optimizations for interrupt and time handling.

    PPC:
    Mostly bug fixes.

    ARM:
    No big features, but many small fixes and prerequisites including:

    - a number of fixes for the arch-timer

    - introducing proper level-triggered semantics for the arch-timers

    - a series of patches to synchronously halt a guest (prerequisite
    for IRQ forwarding)

    - some tracepoint improvements

    - a tweak for the EL2 panic handlers

    - some more VGIC cleanups getting rid of redundant state

    x86:
    Quite a few changes:

    - support for VT-d posted interrupts (i.e. PCI devices can inject
    interrupts directly into vCPUs). This introduces a new
    component (in virt/lib/) that connects VFIO and KVM together.
    The same infrastructure will be used for ARM interrupt
    forwarding as well.

    - more Hyper-V features, though the main one Hyper-V synthetic
    interrupt controller will have to wait for 4.5. These will let
    KVM expose Hyper-V devices.

    - nested virtualization now supports VPID (same as PCID but for
    vCPUs) which makes it quite a bit faster

    - for future hardware that supports NVDIMM, there is support for
    clflushopt, clwb, pcommit

    - support for "split irqchip", i.e. LAPIC in kernel +
    IOAPIC/PIC/PIT in userspace, which reduces the attack surface of
    the hypervisor

    - obligatory smattering of SMM fixes

    - on the guest side, stable scheduler clock support was rewritten
    to not require help from the hypervisor"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (123 commits)
    KVM: VMX: Fix commit which broke PML
    KVM: x86: obey KVM_X86_QUIRK_CD_NW_CLEARED in kvm_set_cr0()
    KVM: x86: allow RSM from 64-bit mode
    KVM: VMX: fix SMEP and SMAP without EPT
    KVM: x86: move kvm_set_irq_inatomic to legacy device assignment
    KVM: device assignment: remove pointless #ifdefs
    KVM: x86: merge kvm_arch_set_irq with kvm_set_msi_inatomic
    KVM: x86: zero apic_arb_prio on reset
    drivers/hv: share Hyper-V SynIC constants with userspace
    KVM: x86: handle SMBASE as physical address in RSM
    KVM: x86: add read_phys to x86_emulate_ops
    KVM: x86: removing unused variable
    KVM: don't pointlessly leave KVM_COMPAT=y in non-KVM configs
    KVM: arm/arm64: Merge vgic_set_lr() and vgic_sync_lr_elrsr()
    KVM: arm/arm64: Clean up vgic_retire_lr() and surroundings
    KVM: arm/arm64: Optimize away redundant LR tracking
    KVM: s390: use simple switch statement as multiplexer
    KVM: s390: drop useless newline in debugging data
    KVM: s390: SCA must not cross page boundaries
    KVM: arm: Do not indent the arguments of DECLARE_BITMAP
    ...

    Linus Torvalds
     
  • Pull documentation update from Jon Corbet:
    "There is a nice new document from Neil on how pathname lookups work
    and some new CAN driver documentation. Beyond that, we have
    kernel-doc fixes, a bit more work to support reproducible builds, and
    the usual collection of small fixes"

    * tag 'docs-for-linus' of git://git.lwn.net/linux: (34 commits)
    Documentation: add new description of path-name lookup.
    Documentation/vm/slub.txt: document slabinfo-gnuplot.sh
    Doc: ABI/stable: Fix typo in ABI/stable
    doc: Clarify that nmi_watchdog param is for hardlockups
    Typo correction for description in gpio document.
    DocBook: Fix kernel-doc to be case-insensitive for private:
    kernel-docs.txt: update kernelnewbies reference
    Doc:kvm: Fix typo in Doc/virtual/kvm
    Documentation/Changes: Add bc in "Current Minimal Requirements" section
    Documentation/email-clients.txt: remove trailing whitespace
    DocBook: Use a fixed encoding for output
    MAINTAINERS: The docs tree has moved
    Docs/kernel-parameters: Add earlycon devicetree usage
    SubmittingPatches: make Subject examples match the de facto standard
    Documentation: gpio: mention that -gpio has been deprecated
    Documentation: cgroups: just fix a few typos
    Documentation: Update kselftest.txt
    Documentation: DMA API: Be more explicit that nents is always the same
    Documentation: Update the default value of crashkernel low
    zram: update documentation
    ...

    Linus Torvalds