26 Jan, 2019

2 commits

  • [ Upstream commit fbac5977d81cb2b2b7e37b11c459055d9585273c ]

    An unterminated string literal followed by new line is passed to the
    parser (with "multi-line strings not supported" warning shown), then
    handled properly there.

    On the other hand, an unterminated string literal at end of file is
    never passed to the parser, then results in memory leak.

    [Test Code]

    ----------(Kconfig begin)----------
    source "Kconfig.inc"

    config A
    bool "a"
    -----------(Kconfig end)-----------

    --------(Kconfig.inc begin)--------
    config B
    bool "b\No new line at end of file
    ---------(Kconfig.inc end)---------

    [Summary from Valgrind]

    Before the fix:

    LEAK SUMMARY:
    definitely lost: 16 bytes in 1 blocks
    ...

    After the fix:

    LEAK SUMMARY:
    definitely lost: 0 bytes in 0 blocks
    ...

    Eliminate the memory leak path by handling this case. Of course, such
    a Kconfig file is wrong already, so I will add an error message later.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin

    Masahiro Yamada
     
  • [ Upstream commit 77c1c0fa8b1477c5799bdad65026ea5ff676da44 ]

    Currently, warn_ignore_character() displays invalid file name and
    line number.

    The lexer should use current_file->name and yylineno, while the parser
    should use zconf_curname() and zconf_lineno().

    This difference comes from that the lexer is always going ahead
    of the parser. The parser needs to look ahead one token to make a
    shift/reduce decision, so the lexer is requested to scan more text
    from the input file.

    This commit fixes the warning message from warn_ignored_character().

    [Test Code]

    ----(Kconfig begin)----
    /
    -----(Kconfig end)-----

    [Output]

    Before the fix:

    :0:warning: ignoring unsupported character '/'

    After the fix:

    Kconfig:1:warning: ignoring unsupported character '/'

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin

    Masahiro Yamada
     

17 Jan, 2019

1 commit

  • commit e4f358916d528d479c3c12bd2fd03f2d5a576380 upstream.

    Commit

    4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")

    replaced the RETPOLINE define with CONFIG_RETPOLINE checks. Remove the
    remaining pieces.

    [ bp: Massage commit message. ]

    Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
    Signed-off-by: WANG Chao
    Signed-off-by: Borislav Petkov
    Reviewed-by: Zhenzhong Duan
    Reviewed-by: Masahiro Yamada
    Cc: "H. Peter Anvin"
    Cc: Andi Kleen
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: Daniel Borkmann
    Cc: David Woodhouse
    Cc: Geert Uytterhoeven
    Cc: Jessica Yu
    Cc: Jiri Kosina
    Cc: Kees Cook
    Cc: Konrad Rzeszutek Wilk
    Cc: Luc Van Oostenryck
    Cc: Michal Marek
    Cc: Miguel Ojeda
    Cc: Peter Zijlstra
    Cc: Tim Chen
    Cc: Vasily Gorbik
    Cc: linux-kbuild@vger.kernel.org
    Cc: srinivas.eeda@oracle.com
    Cc: stable
    Cc: x86-ml
    Link: https://lkml.kernel.org/r/20181210163725.95977-1-chao.wang@ucloud.cn
    Signed-off-by: Greg Kroah-Hartman

    WANG Chao
     

13 Jan, 2019

3 commits

  • commit 1212f7a16af492d59304ba3abccbcc5b5e41423e upstream.

    On arm64, the EFI stub and the kernel proper are essentially the same
    binary, although the EFI stub executes at a different virtual address
    as the kernel. For this reason, the EFI stub is restricted in the
    symbols it can link to, which is ensured by prefixing all EFI stub
    symbols with __efistub_ (and emitting __efistub_ prefixed aliases for
    routines that may be shared between the core kernel and the stub)

    These symbols are leaking into kallsyms, polluting the namespace, so
    let's filter them explicitly.

    Signed-off-by: Ard Biesheuvel
    Signed-off-by: Will Deacon
    Cc: Nick Desaulniers
    Signed-off-by: Greg Kroah-Hartman

    Ard Biesheuvel
     
  • When building to record the mcount locations the kernel uses
    KBUILD_CFLAGS but not KBUILD_CPPFLAGS. This means it lacks
    -Qunused-arguments when building with clang, resulting in a lot of
    noisy warnings.

    Signed-off-by: Joel Stanley
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Masahiro Yamada
    [nc: Fix conflicts due to lack of 87a32e624037 and d503ac531a52]
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Greg Kroah-Hartman

    Joel Stanley
     
  • [ Upstream commit f1733a1d3cd32a9492f4cf866be37bb46e10163d ]

    There is actually a space after "sp," like this,

    ffff2000080813c8: a9bb7bfd stp x29, x30, [sp, #-80]!

    Right now, checkstack.pl isn't able to print anything on aarch64,
    because it won't be able to match the stating objdump line of a function
    due to this missing space. Hence, it displays every stack as zero-size.

    After this patch, checkpatch.pl is able to match the start of a
    function's objdump, and is then able to calculate each function's stack
    correctly.

    Link: http://lkml.kernel.org/r/20181207195843.38528-1-cai@lca.pw
    Signed-off-by: Qian Cai
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Qian Cai
     

08 Dec, 2018

2 commits

  • commit 38c7b224ce22c25fed04007839edf974bd13439d upstream.

    New versions of gcc reasonably warn about the odd pattern of

    strncpy(p, q, strlen(q));

    which really doesn't make sense: the strncpy() ends up being just a slow
    and odd way to write memcpy() in this case.

    There was a comment about _why_ the code used strncpy - to avoid the
    terminating NUL byte, but memcpy does the same and avoids the warning.

    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Linus Torvalds
     
  • commit 321cb0308a9e76841394b4bbab6a1107cfedbae0 upstream.

    gcc-8 reports many -Wpacked-not-aligned warnings. The below are some
    examples.

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    This patch suppresses this kind of warnings for default setting.

    Signed-off-by: Xiongfeng Wang
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    Xiongfeng Wang
     

06 Dec, 2018

1 commit

  • commit 4cd24de3a0980bf3100c9dcb08ef65ca7c31af48 upstream

    Since retpoline capable compilers are widely available, make
    CONFIG_RETPOLINE hard depend on the compiler capability.

    Break the build when CONFIG_RETPOLINE is enabled and the compiler does not
    support it. Emit an error message in that case:

    "arch/x86/Makefile:226: *** You are building kernel with non-retpoline
    compiler, please update your compiler.. Stop."

    [dwmw: Fail the build with non-retpoline compiler]

    Suggested-by: Peter Zijlstra
    Signed-off-by: Zhenzhong Duan
    Signed-off-by: Thomas Gleixner
    Cc: David Woodhouse
    Cc: Borislav Petkov
    Cc: Daniel Borkmann
    Cc: H. Peter Anvin
    Cc: Konrad Rzeszutek Wilk
    Cc: Andy Lutomirski
    Cc: Masahiro Yamada
    Cc: Michal Marek
    Cc:
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/cca0cb20-f9e2-4094-840b-fb0f8810cd34@default
    Signed-off-by: Greg Kroah-Hartman

    Zhenzhong Duan
     

04 Nov, 2018

1 commit

  • [ Upstream commit 56869d45e364244a721de34ce9c5dc9ed022779e ]

    The rule of mainmenu_stmt does not have debug print of zconf_lineno(),
    but if it had, it would print a wrong line number for the same reason
    as commit b2d00d7c61c8 ("kconfig: fix line numbers for if-entries in
    menu tree").

    The mainmenu_stmt does not need to eat following empty lines because
    they are reduced to common_stmt.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin

    Masahiro Yamada
     

26 Sep, 2018

1 commit

  • [ Upstream commit 9c2af1c7377a8a6ef86e5cabf80978f3dbbb25c0 ]

    If Make gets a fatal signal while a shell is executing, it may delete
    the target file that the recipe was supposed to update. This is needed
    to make sure that it is remade from scratch when Make is next run; if
    Make is interrupted after the recipe has begun to write the target file,
    it results in an incomplete file whose time stamp is newer than that
    of the prerequisites files. Make automatically deletes the incomplete
    file on interrupt unless the target is marked .PRECIOUS.

    The situation is just the same as when the shell fails for some reasons.
    Usually when a recipe line fails, if it has changed the target file at
    all, the file is corrupted, or at least it is not completely updated.
    Yet the file’s time stamp says that it is now up to date, so the next
    time Make runs, it will not try to update that file.

    However, Make does not cater to delete the incomplete target file in
    this case. We need to add .DELETE_ON_ERROR somewhere in the Makefile
    to request it.

    scripts/Kbuild.include seems a suitable place to add it because it is
    included from almost all sub-makes.

    Please note .DELETE_ON_ERROR is not effective for phony targets.

    The external module building should never ever touch the kernel tree.
    The following recipe fails if include/generated/autoconf.h is missing.
    However, include/config/auto.conf is not deleted since it is a phony
    target.

    PHONY += include/config/auto.conf

    include/config/auto.conf:
    $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
    echo >&2; \
    echo >&2 " ERROR: Kernel configuration is invalid."; \
    echo >&2 " include/generated/autoconf.h or $@ are missing.";\
    echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
    echo >&2 ; \
    /bin/false)

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Masahiro Yamada
     

15 Sep, 2018

2 commits

  • commit 914b087ff9e0e9a399a4927fa30793064afc0178 upstream.

    When $DEPMOD is not found, only print a warning instead of exiting
    with an error message and error status:

    Warning: 'make modules_install' requires /sbin/depmod. Please install it.
    This is probably in the kmod package.

    Change the Error to a Warning because "not all build hosts for cross
    compiling Linux are Linux systems and are able to provide a working
    port of depmod, especially at the file patch /sbin/depmod."

    I.e., "make modules_install" may be used to copy/install the
    loadable modules files to a target directory on a build system and
    then transferred to an embedded device where /sbin/depmod is run
    instead of it being run on the build system.

    Fixes: 934193a654c1 ("kbuild: verify that $DEPMOD is installed")
    Signed-off-by: Randy Dunlap
    Reported-by: H. Nikolaus Schaller
    Cc: stable@vger.kernel.org
    Cc: Lucas De Marchi
    Cc: Lucas De Marchi
    Cc: Michal Marek
    Cc: Jessica Yu
    Cc: Chih-Wei Huang
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Maxim Zhukov
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • [ Upstream commit 1f3aa9002dc6a0d59a4b599b4fc8f01cf43ef014 ]

    Fix missing error check for memory allocation functions in
    scripts/mod/modpost.c.

    Fixes kernel bugzilla #200319:
    https://bugzilla.kernel.org/show_bug.cgi?id=200319

    Signed-off-by: Randy Dunlap
    Cc: Yuexing Wang
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

05 Sep, 2018

2 commits

  • commit b86729109c5fd0a480300f40608aac68764b5adf upstream.

    GCC 8 changed the order of some fields and is very picky about ordering
    in static initializers, so instead just move to dynamic initializers,
    and drop the redundant already-zero field assignments.

    Suggested-by: Valdis Kletnieks
    Signed-off-by: Kees Cook
    Cc: Lance Albertson
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • commit 80d172431696482d9acd8d2c4ea78fed8956e2a1 upstream.

    GCC requires another #include to get the gcc-plugins to build cleanly.

    Signed-off-by: Valdis Kletnieks
    Signed-off-by: Kees Cook
    Cc: Lance Albertson
    Signed-off-by: Greg Kroah-Hartman

    Valdis Kletnieks
     

24 Aug, 2018

1 commit

  • [ Upstream commit b2d00d7c61c84edd150310af3f556f8a3c6e2e67 ]

    The line numers for if-entries in the menu tree are off by one or more
    lines which is confusing when debugging for correctness of unrelated changes.

    According to the git log, commit a02f0570ae201c49 (kconfig: improve
    error handling in the parser) was the last one that changed that part
    of the parser and replaced

    "if_entry: T_IF expr T_EOL"
    by
    "if_entry: T_IF expr nl"

    but the commit message does not state why this has been done.

    When reverting that part of the commit, only the line numers are
    corrected (checked with cdebug = DEBUG_PARSE in zconf.y), otherwise
    the menu tree remains unchanged (checked with zconfdump() enabled in
    conf.c).

    An example for the corrected line numbers:

    drivers/soc/Kconfig:15:source drivers/soc/tegra/Kconfig
    drivers/soc/tegra/Kconfig:4:if
    drivers/soc/tegra/Kconfig:6:if

    changes to:

    drivers/soc/Kconfig:15:source drivers/soc/tegra/Kconfig
    drivers/soc/tegra/Kconfig:1:if
    drivers/soc/tegra/Kconfig:4:if

    Signed-off-by: Dirk Gouders
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dirk Gouders
     

18 Aug, 2018

1 commit

  • commit 934193a654c1f4d0643ddbf4b2529b508cae926e upstream.

    Verify that 'depmod' ($DEPMOD) is installed.
    This is a partial revert of commit 620c231c7a7f
    ("kbuild: do not check for ancient modutils tools").

    Also update Documentation/process/changes.rst to refer to
    kmod instead of module-init-tools.

    Fixes kernel bugzilla #198965:
    https://bugzilla.kernel.org/show_bug.cgi?id=198965

    Signed-off-by: Randy Dunlap
    Cc: Lucas De Marchi
    Cc: Lucas De Marchi
    Cc: Michal Marek
    Cc: Jessica Yu
    Cc: Chih-Wei Huang
    Cc: stable@vger.kernel.org # any kernel since 2012
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

11 Jul, 2018

1 commit

  • commit 9564a8cf422d7b58f6e857e3546d346fa970191e upstream.

    I tried building using a freshly built Make (4.2.1-69-g8a731d1), but
    already the objtool build broke with

    orc_dump.c: In function ‘orc_dump’:
    orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
    if (elf_getshdrnum(elf, &nr_sections)) {

    Turns out that with that new Make, the backslash was not removed, so cpp
    didn't see a #include directive, grep found nothing, and
    -DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS.

    Now, that new Make behaviour is documented in their NEWS file:

    * WARNING: Backward-incompatibility!
    Number signs (#) appearing inside a macro reference or function invocation
    no longer introduce comments and should not be escaped with backslashes:
    thus a call such as:
    foo := $(shell echo '#')
    is legal. Previously the number sign needed to be escaped, for example:
    foo := $(shell echo '\#')
    Now this latter will resolve to "\#". If you want to write makefiles
    portable to both versions, assign the number sign to a variable:
    C := \#
    foo := $(shell echo '$C')
    This was claimed to be fixed in 3.81, but wasn't, for some reason.
    To detect this change search for 'nocomment' in the .FEATURES variable.

    This also fixes up the two make-cmd instances to replace # with $(pound)
    rather than with \#. There might very well be other places that need
    similar fixup in preparation for whatever future Make release contains
    the above change, but at least this builds an x86_64 defconfig with the
    new make.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847
    Cc: Randy Dunlap
    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    Rasmus Villemoes
     

12 Jun, 2018

1 commit

  • commit 2ae89c7a82ea9d81a19b4fc2df23bef4b112f24e upstream.

    In file included from scripts/kconfig/zconf.tab.c:2485:
    scripts/kconfig/confdata.c: In function ‘conf_write’:
    scripts/kconfig/confdata.c:773:22: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
    sprintf(newname, "%s%s", dirname, basename);
    ^~
    scripts/kconfig/confdata.c:773:19: note: assuming directive output of 7 bytes
    sprintf(newname, "%s%s", dirname, basename);
    ^~~~~~
    scripts/kconfig/confdata.c:773:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097
    sprintf(newname, "%s%s", dirname, basename);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    scripts/kconfig/confdata.c:776:23: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
    sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
    ^~~~~~~~~~~
    scripts/kconfig/confdata.c:776:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097
    sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Increase the size of tmpname and newname to make GCC happy.

    Signed-off-by: Nathan Chancellor
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    Nathan Chancellor
     

30 May, 2018

2 commits

  • [ Upstream commit f8437520704cfd9cc442a99d73ed708a3cdadaf9 ]

    Since d5d332d3f7e8, a couple of links in scripts/dtc/include-prefixes
    are additionally required in order to build device trees with the header
    package.

    Signed-off-by: Jan Kiszka
    Reviewed-by: Riku Voipio
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jan Kiszka
     
  • [ Upstream commit 825d487583089f9a33d31650c9c41f6474aab7fc ]

    Some filesystems have timestamps with coarse precision that may allow
    for a recently built object file to have the same timestamp as the
    updated time on one of its dependency files. When that happens, the
    object file doesn't get rebuilt as it should.

    This is especially the case on filesystems that don't have sub-second
    time precision, such as ext3 or Ext4 with 128B inodes.

    Let's prevent that by making sure updated dependency files have a newer
    timestamp than the first file we created (i.e. autoksyms.h.tmpnew).

    Reported-by: Thomas Lindroth
    Signed-off-by: Nicolas Pitre
    Tested-by: Thomas Lindroth
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Nicolas Pitre
     

26 Apr, 2018

3 commits

  • [ Upstream commit 5b1374b3b3c2fc4f63a398adfa446fb8eff791a4 ]

    Only the E_NOT operand and not the E_NOT node itself was freed, due to
    accidentally returning too early in expr_free(). Outline of leak:

    switch (e->type) {
    ...
    case E_NOT:
    expr_free(e->left.expr);
    return;
    ...
    }
    *Never reached, 'e' leaked*
    free(e);

    Fix by changing the 'return' to a 'break'.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 44,448 bytes in 1,852 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 1,608 bytes in 67 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ulf Magnusson
     
  • [ Upstream commit ae7440ef0c8013d68c00dad6900e7cce5311bb1c ]

    expr_trans_compare() always allocates and returns a new expression,
    giving the following leak outline:

    ...
    *Allocate*
    basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
    ...
    for (menu = parent->next; menu; menu = menu->next) {
    ...
    *Copy*
    dep2 = expr_copy(basedep);
    ...
    *Free copy*
    expr_free(dep2);
    }
    *basedep lost!*

    Fix by freeing 'basedep' after the loop.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 344,376 bytes in 14,349 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 44,448 bytes in 1,852 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ulf Magnusson
     
  • [ Upstream commit 0724a7c32a54e3e50d28e19e30c59014f61d4e2c ]

    If a 'mainmenu' entry appeared in the Kconfig files, two things would
    leak:

    - The 'struct property' allocated for the default "Linux Kernel
    Configuration" prompt.

    - The string for the T_WORD/T_WORD_QUOTE prompt after the
    T_MAINMENU token, allocated on the heap in zconf.l.

    To fix it, introduce a new 'no_mainmenu_stmt' nonterminal that matches
    if there's no 'mainmenu' and adds the default prompt. That means the
    prompt only gets allocated once regardless of whether there's a
    'mainmenu' statement or not, and managing it becomes simple.

    Summary from Valgrind on 'menuconfig' (ARCH=x86) before the fix:

    LEAK SUMMARY:
    definitely lost: 344,568 bytes in 14,352 blocks
    ...

    Summary after the fix:

    LEAK SUMMARY:
    definitely lost: 344,440 bytes in 14,350 blocks
    ...

    Signed-off-by: Ulf Magnusson
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ulf Magnusson
     

24 Mar, 2018

1 commit

  • commit 86a9df597cdd564d2d29c65897bcad42519e3678 upstream.

    I was not seeing my linker flags getting added when using ld-option when
    cross compiling with Clang. Upon investigation, this seems to be due to
    a difference in how GCC vs Clang handle cross compilation.

    GCC is configured at build time to support one backend, that is implicit
    when compiling. Clang is explicit via the use of `-target ` and
    ships with all supported backends by default.

    GNU Make feature test macros that compile then link will always fail
    when cross compiling with Clang unless Clang's triple is passed along to
    the compiler. For example:

    $ clang -x c /dev/null -c -o temp.o
    $ aarch64-linux-android/bin/ld -E temp.o
    aarch64-linux-android/bin/ld:
    unknown architecture of input file `temp.o' is incompatible with
    aarch64 output
    aarch64-linux-android/bin/ld:
    warning: cannot find entry symbol _start; defaulting to
    0000000000400078
    $ echo $?
    1

    $ clang -target aarch64-linux-android- -x c /dev/null -c -o temp.o
    $ aarch64-linux-android/bin/ld -E temp.o
    aarch64-linux-android/bin/ld:
    warning: cannot find entry symbol _start; defaulting to 00000000004002e4
    $ echo $?
    0

    This causes conditional checks that invoke $(CC) without the target
    triple, then $(LD) on the result, to always fail.

    Suggested-by: Masahiro Yamada
    Signed-off-by: Nick Desaulniers
    Reviewed-by: Matthias Kaehlcke
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Hackmann
    Signed-off-by: Greg Kroah-Hartman

    Nick Desaulniers
     

15 Mar, 2018

4 commits

  • commit d5028ba8ee5a18c9d0bb926d883c28b370f89009 upstream.

    Disable retpoline validation in objtool if your compiler sucks, and otherwise
    select the validation stuff for CONFIG_RETPOLINE=y (most builds would already
    have it set due to ORC).

    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Thomas Gleixner
    Cc: Andy Lutomirski
    Cc: Arjan van de Ven
    Cc: Borislav Petkov
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: David Woodhouse
    Cc: Greg Kroah-Hartman
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     
  • commit ca41b97ed9124fd62323a162de5852f6e28f94b8 upstream.

    David allowed retpolines in .init.text, except for modules, which will
    trip up objtool retpoline validation, fix that.

    Requested-by: David Woodhouse
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Thomas Gleixner
    Acked-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Arjan van de Ven
    Cc: Borislav Petkov
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: David Woodhouse
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     
  • commit b5bc2231b8ad4387c9641f235ca0ad8cd300b6df upstream.

    David requested a objtool validation pass for CONFIG_RETPOLINE=y enabled
    builds, where it validates no unannotated indirect jumps or calls are
    left.

    Add an additional .discard.retpoline_safe section to allow annotating
    the few indirect sites that are required and safe.

    Requested-by: David Woodhouse
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: David Woodhouse
    Acked-by: Thomas Gleixner
    Acked-by: Josh Poimboeuf
    Cc: Andy Lutomirski
    Cc: Arjan van de Ven
    Cc: Borislav Petkov
    Cc: Dan Williams
    Cc: Dave Hansen
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     
  • commit 55fe6da9efba102866e2fb5b40b04b6a4b26c19e upstream.

    cmd_dt_S_dtb constructs the assembly source to incorporate a devicetree
    FDT (that is, the .dtb file) as binary data in the kernel image. This
    assembly source contains labels before and after the binary data. The
    label names incorporate the file name of the corresponding .dtb file.
    Hyphens are not legal characters in labels, so .dtb files built into the
    kernel with hyphens in the file name result in errors like the
    following:

    bcm3368-netgear-cvg834g.dtb.S: Assembler messages:
    bcm3368-netgear-cvg834g.dtb.S:5: Error: : no such section
    bcm3368-netgear-cvg834g.dtb.S:5: Error: junk at end of line, first unrecognized character is `-'
    bcm3368-netgear-cvg834g.dtb.S:6: Error: unrecognized opcode `__dtb_bcm3368-netgear-cvg834g_begin:'
    bcm3368-netgear-cvg834g.dtb.S:8: Error: unrecognized opcode `__dtb_bcm3368-netgear-cvg834g_end:'
    bcm3368-netgear-cvg834g.dtb.S:9: Error: : no such section
    bcm3368-netgear-cvg834g.dtb.S:9: Error: junk at end of line, first unrecognized character is `-'

    Fix this by updating cmd_dt_S_dtb to transform all hyphens from the file
    name to underscores when constructing the labels.

    As of v4.16-rc2, 1139 .dts files across ARM64, ARM, MIPS and PowerPC
    contain hyphens in their names, but the issue only currently manifests
    on Broadcom MIPS platforms, as that is the only place where such files
    are built into the kernel. For example when CONFIG_DT_NETGEAR_CVG834G=y,
    or on BMIPS kernels when the dtbs target is used (in the latter case it
    admittedly shouldn't really build all the dtb.o files, but thats a
    separate issue).

    Fixes: 695835511f96 ("MIPS: BMIPS: rename bcm96358nb4ser to bcm6358-neufbox4-sercom")
    Signed-off-by: James Hogan
    Reviewed-by: Frank Rowand
    Cc: Rob Herring
    Cc: Michal Marek
    Cc: Ralf Baechle
    Cc: Florian Fainelli
    Cc: Kevin Cernekee
    Cc: # 4.9+
    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    James Hogan
     

25 Feb, 2018

1 commit

  • [ Upstream commit e814bccbafece52a24e152d2395b5d49eef55841 ]

    My bisect scripts starting running into build failures when trying to
    compile 4.15-rc1 with the builds failing with things like:

    drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:2078: error: Cannot parse struct or union!

    The line in question is actually just a #define, but after some digging
    it turns out that my scripts pass W=1 and since commit 3a025e1d1c2ea
    ("Add optional check for bad kernel-doc comments") that results in
    kernel-doc running on each source file. The file in question has a
    badly formatted comment immediately before the #define:

    /**
    * struct brcmf_skbuff_cb reserves first two bytes in sk_buff::cb for
    * bus layer usage.
    */

    which causes the regex in dump_struct to fail (lack of braces following
    struct declaration) and kernel-doc returns 1, which causes the build
    to fail.

    Fix the issue by always returning 0 from kernel-doc when invoked with
    -none. It successfully generates no documentation, and prints out any
    issues.

    Cc: Matthew Wilcox
    Cc: Jonathan Corbet
    Signed-off-by: Will Deacon
    Signed-off-by: Jonathan Corbet
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Will Deacon
     

22 Feb, 2018

1 commit

  • commit 4675ff05de2d76d167336b368bd07f3fef6ed5a6 upstream.

    Fix up makefiles, remove references, and git rm kmemcheck.

    Link: http://lkml.kernel.org/r/20171007030159.22241-4-alexander.levin@verizon.com
    Signed-off-by: Sasha Levin
    Cc: Steven Rostedt
    Cc: Vegard Nossum
    Cc: Pekka Enberg
    Cc: Michal Hocko
    Cc: Eric W. Biederman
    Cc: Alexander Potapenko
    Cc: Tim Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Levin, Alexander (Sasha Levin)
     

17 Feb, 2018

2 commits

  • commit e7c52b84fb18f08ce49b6067ae6285aca79084a8 upstream.

    We get a lot of very large stack frames using gcc-7.0.1 with the default
    -fsanitize-address-use-after-scope --param asan-stack=1 options, which can
    easily cause an overflow of the kernel stack, e.g.

    drivers/gpu/drm/i915/gvt/handlers.c:2434:1: warning: the frame size of 46176 bytes is larger than 3072 bytes
    drivers/net/wireless/ralink/rt2x00/rt2800lib.c:5650:1: warning: the frame size of 23632 bytes is larger than 3072 bytes
    lib/atomic64_test.c:250:1: warning: the frame size of 11200 bytes is larger than 3072 bytes
    drivers/gpu/drm/i915/gvt/handlers.c:2621:1: warning: the frame size of 9208 bytes is larger than 3072 bytes
    drivers/media/dvb-frontends/stv090x.c:3431:1: warning: the frame size of 6816 bytes is larger than 3072 bytes
    fs/fscache/stats.c:287:1: warning: the frame size of 6536 bytes is larger than 3072 bytes

    To reduce this risk, -fsanitize-address-use-after-scope is now split out
    into a separate CONFIG_KASAN_EXTRA Kconfig option, leading to stack
    frames that are smaller than 2 kilobytes most of the time on x86_64. An
    earlier version of this patch also prevented combining KASAN_EXTRA with
    KASAN_INLINE, but that is no longer necessary with gcc-7.0.1.

    All patches to get the frame size below 2048 bytes with CONFIG_KASAN=y
    and CONFIG_KASAN_EXTRA=n have been merged by maintainers now, so we can
    bring back that default now. KASAN_EXTRA=y still causes lots of
    warnings but now defaults to !COMPILE_TEST to disable it in
    allmodconfig, and it remains disabled in all other defconfigs since it
    is a new option. I arbitrarily raise the warning limit for KASAN_EXTRA
    to 3072 to reduce the noise, but an allmodconfig kernel still has around
    50 warnings on gcc-7.

    I experimented a bit more with smaller stack frames and have another
    follow-up series that reduces the warning limit for 64-bit architectures
    to 1280 bytes (without CONFIG_KASAN).

    With earlier versions of this patch series, I also had patches to address
    the warnings we get with KASAN and/or KASAN_EXTRA, using a
    "noinline_if_stackbloat" annotation.

    That annotation now got replaced with a gcc-8 bugfix (see
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81715) and a workaround for
    older compilers, which means that KASAN_EXTRA is now just as bad as
    before and will lead to an instant stack overflow in a few extreme
    cases.

    This reverts parts of commit 3f181b4d8652 ("lib/Kconfig.debug: disable
    -Wframe-larger-than warnings with KASAN=y"). Two patches in linux-next
    should be merged first to avoid introducing warnings in an allmodconfig
    build:
    3cd890dbe2a4 ("media: dvb-frontends: fix i2c access helpers for KASAN")
    16c3ada89cff ("media: r820t: fix r820t_write_reg for KASAN")

    Do we really need to backport this?

    I think we do: without this patch, enabling KASAN will lead to
    unavoidable kernel stack overflow in certain device drivers when built
    with gcc-7 or higher on linux-4.10+ or any version that contains a
    backport of commit c5caf21ab0cf8. Most people are probably still on
    older compilers, but it will get worse over time as they upgrade their
    distros.

    The warnings we get on kernels older than this should all be for code
    that uses dangerously large stack frames, though most of them do not
    cause an actual stack overflow by themselves.The asan-stack option was
    added in linux-4.0, and commit 3f181b4d8652 ("lib/Kconfig.debug:
    disable -Wframe-larger-than warnings with KASAN=y") effectively turned
    off the warning for allmodconfig kernels, so I would like to see this
    fix backported to any kernels later than 4.0.

    I have done dozens of fixes for individual functions with stack frames
    larger than 2048 bytes with asan-stack, and I plan to make sure that
    all those fixes make it into the stable kernels as well (most are
    already there).

    Part of the complication here is that asan-stack (from 4.0) was
    originally assumed to always require much larger stacks, but that
    turned out to be a combination of multiple gcc bugs that we have now
    worked around and fixed, but sanitize-address-use-after-scope (from
    v4.10) has a much higher inherent stack usage and also suffers from at
    least three other problems that we have analyzed but not yet fixed
    upstream, each of them makes the stack usage more severe than it should
    be.

    Link: http://lkml.kernel.org/r/20171221134744.2295529-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Acked-by: Andrey Ryabinin
    Cc: Mauro Carvalho Chehab
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Cc: Andrey Konovalov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • commit 0e410e158e5baa1300bdf678cea4f4e0cf9d8b94 upstream.

    With KASAN enabled the kernel has two different memset() functions, one
    with KASAN checks (memset) and one without (__memset). KASAN uses some
    macro tricks to use the proper version where required. For example
    memset() calls in mm/slub.c are without KASAN checks, since they operate
    on poisoned slab object metadata.

    The issue is that clang emits memset() calls even when there is no
    memset() in the source code. They get linked with improper memset()
    implementation and the kernel fails to boot due to a huge amount of KASAN
    reports during early boot stages.

    The solution is to add -fno-builtin flag for files with KASAN_SANITIZE :=
    n marker.

    Link: http://lkml.kernel.org/r/8ffecfffe04088c52c42b92739c2bd8a0bcb3f5e.1516384594.git.andreyknvl@google.com
    Signed-off-by: Andrey Konovalov
    Acked-by: Nick Desaulniers
    Cc: Masahiro Yamada
    Cc: Michal Marek
    Cc: Andrey Ryabinin
    Cc: Alexander Potapenko
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Andrey Konovalov
     

13 Feb, 2018

1 commit

  • commit af60e207087975d069858741c44ed4f450330ac4 upstream.

    If build fails during (bin)rpm-pkg, the spec file is not cleaned by
    anyone until the next successful build of the package.

    We do not have to immediately delete the spec file in case somebody
    may want to take a look at it. Instead, make them ignored by git,
    and cleaned up by make mrproper.

    Signed-off-by: Masahiro Yamada
    Signed-off-by: Greg Kroah-Hartman

    Masahiro Yamada
     

08 Feb, 2018

2 commits

  • commit caf7501a1b4ec964190f31f9c3f163de252273b8

    There's a risk that a kernel which has full retpoline mitigations becomes
    vulnerable when a module gets loaded that hasn't been compiled with the
    right compiler or the right option.

    To enable detection of that mismatch at module load time, add a module info
    string "retpoline" at build time when the module was compiled with
    retpoline support. This only covers compiled C source, but assembler source
    or prebuilt object files are not checked.

    If a retpoline enabled kernel detects a non retpoline protected module at
    load time, print a warning and report it in the sysfs vulnerability file.

    [ tglx: Massaged changelog ]

    Signed-off-by: Andi Kleen
    Signed-off-by: Thomas Gleixner
    Cc: David Woodhouse
    Cc: gregkh@linuxfoundation.org
    Cc: torvalds@linux-foundation.org
    Cc: jeyu@kernel.org
    Cc: arjan@linux.intel.com
    Link: https://lkml.kernel.org/r/20180125235028.31211-1-andi@firstfloor.org
    Signed-off-by: Greg Kroah-Hartman

    Andi Kleen
     
  • commit 4cc90b4cc3d4955f79eae4f7f9d64e67e17b468e upstream.

    faddr2line hit var unbound error when CROSS_COMPILE isn't set since
    nounset option is set in bash script.

    Link: http://lkml.kernel.org/r/20171206013022.GA83929@sofia
    Fixes: 95a879825419 ("scripts/faddr2line: extend usage on generic arch")
    Signed-off-by: Liu Changcheng
    Reported-by: Richard Weinberger
    Reviewed-by: Richard Weinberger
    Cc: Thomas Gleixner
    Cc: Greg Kroah-Hartman
    Cc: Philippe Ombredanne
    Cc: NeilBrown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Liu, Changcheng
     

04 Feb, 2018

1 commit

  • [ Upstream commit 95a87982541932503d3f59aba4c30b0bde0a6294 ]

    When cross-compiling, fadd2line should use the binary tool used for the
    target system, rather than that of the host.

    Link: http://lkml.kernel.org/r/20171121092911.GA150711@sofia
    Signed-off-by: Liu Changcheng
    Cc: Kate Stewart
    Cc: NeilBrown
    Cc: Thomas Gleixner
    Cc: Greg Kroah-Hartman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Liu, Changcheng
     

24 Jan, 2018

2 commits

  • commit 883d50f56d263f70fd73c0d96b09eb36c34e9305 upstream.

    Since kernel 4.9, the thread_info has been moved into task_struct, no
    longer locates at the bottom of kernel stack.

    See commits c65eacbe290b ("sched/core: Allow putting thread_info into
    task_struct") and 15f4eae70d36 ("x86: Move thread_info into
    task_struct").

    Before fix:
    (gdb) set $current = $lx_current()
    (gdb) p $lx_thread_info($current)
    $1 = {flags = 1470918301}
    (gdb) p $current.thread_info
    $2 = {flags = 2147483648}

    After fix:
    (gdb) p $lx_thread_info($current)
    $1 = {flags = 2147483648}
    (gdb) p $current.thread_info
    $2 = {flags = 2147483648}

    Link: http://lkml.kernel.org/r/20180118210159.17223-1-imxikangjie@gmail.com
    Fixes: 15f4eae70d36 ("x86: Move thread_info into task_struct")
    Signed-off-by: Xi Kangjie
    Acked-by: Jan Kiszka
    Acked-by: Kieran Bingham
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Xi Kangjie
     
  • commit 2a0098d70640dda192a79966c14d449e7a34d675 upstream.

    Objtool segfaults when the gold linker is used with
    CONFIG_MODVERSIONS=y and CONFIG_UNWINDER_ORC=y.

    With CONFIG_MODVERSIONS=y, the .o file gets passed to the linker before
    being passed to objtool. The gold linker seems to strip unused ELF
    symbols by default, which confuses objtool and causes the seg fault when
    it's trying to generate ORC metadata.

    Objtool should really be running immediately after GCC anyway, without a
    linker call in between. Change the makefile ordering so that objtool is
    called before the linker.

    Reported-and-tested-by: Markus
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: ee9f8fce9964 ("x86/unwind: Add the ORC unwinder")
    Link: http://lkml.kernel.org/r/355f04da33581f4a3bf82e5b512973624a1e23a2.1516025651.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar
    Cc: Guenter Roeck
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     

25 Dec, 2017

1 commit

  • commit d15155824c5014803d91b829736d249c500bdda6 upstream.

    linux/compiler.h is included indirectly by linux/types.h via
    uapi/linux/types.h -> uapi/linux/posix_types.h -> linux/stddef.h
    -> uapi/linux/stddef.h and is needed to provide a proper definition of
    offsetof.

    Unfortunately, compiler.h requires a definition of
    smp_read_barrier_depends() for defining lockless_dereference() and soon
    for defining READ_ONCE(), which means that all
    users of READ_ONCE() will need to include asm/barrier.h to avoid splats
    such as:

    In file included from include/uapi/linux/stddef.h:1:0,
    from include/linux/stddef.h:4,
    from arch/h8300/kernel/asm-offsets.c:11:
    include/linux/list.h: In function 'list_empty':
    >> include/linux/compiler.h:343:2: error: implicit declaration of function 'smp_read_barrier_depends' [-Werror=implicit-function-declaration]
    smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \
    ^

    A better alternative is to include asm/barrier.h in linux/compiler.h,
    but this requires a type definition for "bool" on some architectures
    (e.g. x86), which is defined later by linux/types.h. Type "bool" is also
    used directly in linux/compiler.h, so the whole thing is pretty fragile.

    This patch splits compiler.h in two: compiler_types.h contains type
    annotations, definitions and the compiler-specific parts, whereas
    compiler.h #includes compiler-types.h and additionally defines macros
    such as {READ,WRITE.ACCESS}_ONCE().

    uapi/linux/stddef.h and linux/linkage.h are then moved over to include
    linux/compiler_types.h, which fixes the build for h8 and blackfin.

    Signed-off-by: Will Deacon
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1508840570-22169-2-git-send-email-will.deacon@arm.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Will Deacon