Skip to content
Snippets Groups Projects
  1. Mar 13, 2019
  2. Mar 11, 2019
  3. Mar 08, 2019
  4. Mar 07, 2019
  5. Mar 06, 2019
  6. Mar 04, 2019
    • Kees Cook's avatar
      gcc-plugins: structleak: Generalize to all variable types · 81a56f6d
      Kees Cook authored
      
      This adjusts structleak to also work with non-struct types when they
      are passed by reference, since those variables may leak just like
      anything else. This is exposed via an improved set of Kconfig options.
      (This does mean structleak is slightly misnamed now.)
      
      Building with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL should give the
      kernel complete initialization coverage of all stack variables passed
      by reference, including padding (see lib/test_stackinit.c).
      
      Using CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE to count added initializations
      under defconfig:
      
      	..._BYREF:      5945 added initializations
      	..._BYREF_ALL: 16606 added initializations
      
      There is virtually no change to text+data size (both have less than 0.05%
      growth):
      
         text    data     bss     dec     hex filename
      19502103        5051456 1917000 26470559        193e89f vmlinux.stock
      19513412        5051456 1908808 26473676        193f4cc vmlinux.byref
      19516974        5047360 1900616 26464950        193d2b6 vmlinux.byref_all
      
      The measured performance difference is in the noise for hackbench and
      kernel build benchmarks:
      
      Stock:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.649s
      	Std Dev: 0.339
      
      	5x kernel build (4-way parallel)
      	Mean:  261.98s
      	Std Dev: 1.53
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.540s
      	Std Dev: 0.233
      
      	5x kernel build (4-way parallel)
      	Mean:  260.52s
      	Std Dev: 1.31
      
      CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL:
      
      	5x hackbench -g 20 -l 1000
      	Mean:   10.320
      	Std Dev: 0.413
      
      	5x kernel build (4-way parallel)
      	Mean:  260.10
      	Std Dev: 0.86
      
      This does not yet solve missing padding initialization for structures
      on the stack that are never passed by reference (which should be a tiny
      minority). Hopefully this will be more easily addressed by upstream
      compiler fixes after clarifying the C11 padding initialization
      specification.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      81a56f6d
    • Masahiro Yamada's avatar
      kbuild: clean up scripts/gcc-version.sh · fa7295ab
      Masahiro Yamada authored
      
      Now that the Kconfig is the only user of this script, we can drop
      unneeded code.
      
      Remove the -p option, and stop prepending the output with zero,
      so that Kconfig can directly use the output from this script.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      fa7295ab
    • Masahiro Yamada's avatar
      kbuild: remove cc-version macro · d3a918c6
      Masahiro Yamada authored
      
      There is no more direct user of this macro; it is only used by
      cc-ifversion.
      
      Calling this macro is not efficient since it invokes the compiler to
      get the compiler version. CONFIG_GCC_VERSION is already calculated in
      the Kconfig stage, so Makefile can reuse it.
      
      Here is a note about the slight difference between cc-version and
      CONFIG_GCC_VERSION:
      
      When using Clang, cc-version is evaluated to '0402' because Clang
      defines __GNUC__ and __GNUC__MINOR__, and looks like GCC 4.2 in the
      version point of view. On the other hand, CONFIG_GCC_VERSION=0
      when $(CC) is clang.
      
      There are currently two users of cc-ifversion:
        arch/mips/loongson64/Platform
        arch/powerpc/Makefile
      
      They are not affected by this change.
      
      The format of cc-version is <major><minor>, while CONFIG_GCC_VERSION
      <major><minor><patch>. I adjusted cc-ifversion for the difference of
      the number of digits.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d3a918c6
    • Masahiro Yamada's avatar
      kbuild: update comment block of scripts/clang-version.sh · 00250b52
      Masahiro Yamada authored
      
      Commit 469cb737 ("kconfig: add CC_IS_CLANG and CLANG_VERSION")
      changed the code, but missed to update the comment block.
      
      The -p option was gone, and the output is 5-digit (or 6-digit when
      Clang 10 is released).
      
      Update the comment now.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      00250b52
  7. Mar 01, 2019
    • Arnd Bergmann's avatar
      kasan: turn off asan-stack for clang-8 and earlier · 6baec880
      Arnd Bergmann authored
      Building an arm64 allmodconfig kernel with clang results in over 140
      warnings about overly large stack frames, the worst ones being:
      
        drivers/gpu/drm/panel/panel-sitronix-st7789v.c:196:12: error: stack frame size of 20224 bytes in function 'st7789v_prepare'
        drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td028ttec1.c:196:12: error: stack frame size of 13120 bytes in function 'td028ttec1_panel_enable'
        drivers/usb/host/max3421-hcd.c:1395:1: error: stack frame size of 10048 bytes in function 'max3421_spi_thread'
        drivers/net/wan/slic_ds26522.c:209:12: error: stack frame size of 9664 bytes in function 'slic_ds26522_probe'
        drivers/crypto/ccp/ccp-ops.c:2434:5: error: stack frame size of 8832 bytes in function 'ccp_run_cmd'
        drivers/media/dvb-frontends/stv0367.c:1005:12: error: stack frame size of 7840 bytes in function 'stv0367ter_algo'
      
      None of these happen with gcc today, and almost all of these are the
      result of a single known issue in llvm.  Hopefully it will eventually
      get fixed with the clang-9 release.
      
      In the meantime, the best idea I have is to turn off asan-stack for
      clang-8 and earlier, so we can produce a kernel that is safe to run.
      
      I have posted three patches that address the frame overflow warnings
      that are not addressed by turning off asan-stack, so in combination with
      this change, we get much closer to a clean allmodconfig build, which in
      turn is necessary to do meaningful build regression testing.
      
      It is still possible to turn on the CONFIG_ASAN_STACK option on all
      versions of clang, and it's always enabled for gcc, but when
      CONFIG_COMPILE_TEST is set, the option remains invisible, so
      allmodconfig and randconfig builds (which are normally done with a
      forced CONFIG_COMPILE_TEST) will still result in a mostly clean build.
      
      Link: http://lkml.kernel.org/r/20190222222950.3997333-1-arnd@arndb.de
      Link: https://bugs.llvm.org/show_bug.cgi?id=38809
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarQian Cai <cai@lca.pw>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Acked-by: default avatarAndrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Kostya Serebryany <kcc@google.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6baec880
  8. Feb 28, 2019
  9. Feb 27, 2019
    • Masahiro Yamada's avatar
      kbuild: move ".config not found!" message from Kconfig to Makefile · 05850719
      Masahiro Yamada authored
      
      If you run "make" in a pristine source tree, currently Kbuild will
      start to build Kconfig to let it show the error message.
      
      It would be more straightforward to check it in Makefile and let
      it fail immediately.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      05850719
    • Masahiro Yamada's avatar
      kbuild: refactor cc-cross-prefix implementation · bd55f96f
      Masahiro Yamada authored
      
      - $(word 1, <text>) is equivalent to $(firstword <text>)
      
       - hardcode "gcc" instead of $(CC)
      
       - minimize the shell script part
      
      A little more notes in case $(filter-out -%, ...) is not clear.
      
      arch/mips/Makefile passes prefixes depending on the configuration.
      
      CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- \
          $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-)
      
      In the Kconfig stage (e.g. when you run 'make defconfig'), neither
      CONFIG_32BIT nor CONFIG_64BIT is defined. So, $(tool-archpref) is
      empty. As a result, "-linux -linux-gnu- -unknown-linux-gnu" is passed
      into cc-cross-prefix. The command 'which' assumes arguments starting
      with a hyphen as command options, then emits the following messages:
      
        Illegal option -l
        Illegal option -l
        Illegal option -u
      
      I think it is strange to define CROSS_COMPILE depending on the CONFIG
      options since you need to feed $(CC) to Kconfig, but it is how MIPS
      Makefile currently works. Anyway, it would not hurt to filter-out
      invalid strings beforehand.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      bd55f96f
    • Masahiro Yamada's avatar
      kbuild: hardcode genksyms path and remove GENKSYMS variable · 88110713
      Masahiro Yamada authored
      
      The genksyms source was integrated into the kernel tree in 2003.
      
      I do not expect anybody still using the external /sbin/genksyms.
      Kbuild does not need to provide the ability to override GENKSYMS.
      
      Let's remove the GENKSYMS variable, and use the hardcoded path.
      
      Since it occurred in the pre-git era, I attached the commit message
      in case somebody is interested in the historical background.
      
        | Author: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
        | Date:   Wed Feb 19 04:17:28 2003 -0600
        |
        | kbuild: [PATCH] put genksyms in scripts dir
        |
        | This puts genksyms into scripts/genksyms/.
        |
        | genksyms used to be maintained externally, though the only possible user
        | was the kernel build. Moving it into the kernel sources makes it easier to
        | keep it uptodate, like for example updating it to generate linker scripts
        | directly instead of postprocessing the generated header file fragments
        | with sed, as we do currently.
        |
        | Also, genksyms does not handle __typeof__, which needs to be fixed since
        | some of the exported symbol in the kernel are defined using __typeof__.
        |
        | (Rusty Russell/me)
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      88110713
    • Masahiro Yamada's avatar
      scripts/gdb: refactor rules for symlink creation · b513adf4
      Masahiro Yamada authored
      
      gdb-scripts is not a real object, but (ab)used like a phony target.
      
      Rewrite the code in a more Kbuild-ish way. Add symlinks to extra-y
      and use if_changed.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      b513adf4
    • Masahiro Yamada's avatar
      scripts/gdb: do not descend into scripts/gdb from scripts · 1e5ff84f
      Masahiro Yamada authored
      
      Currently, Kbuild descends from scripts/Makefile to scripts/gdb/Makefile
      just for creating symbolic links, but it does not need to do it so early.
      
      Merge the two descending paths to simplify the code.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
      1e5ff84f
  10. Feb 22, 2019
    • Aurélien Cedeyn's avatar
      scripts/spdxcheck.py: fix C++ comment style detection · a5f4cb42
      Aurélien Cedeyn authored
      
      With the last commit to support the SuperH boot code files, we have the
      following regression:
      
      $ ./scripts/checkpatch.pl -f <(echo '/* SPDX-License-Identifier: MIT */')
      WARNING: 'SPDX-License-Identifier: MIT */' is not supported in LICENSES/..
      +/* SPDX-License-Identifier: MIT */
      
      total: 0 errors, 1 warnings, 1 lines checked
      
      NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.
      
      /dev/fd/63 has style problems, please review.
      
      NOTE: If any of the errors are false positives, please report
            them to the maintainer, see CHECKPATCH in MAINTAINERS.
      
      This is not obvious, but spdxcheck.py is launched in checkpatch.pl with :
          ...
          } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) {
              my $spdx_license = $1;
              if (!is_SPDX_License_valid($spdx_license)) {
                  WARN("SPDX_LICENSE_TAG",
                       "'$spdx_license' is not supported in LICENSES/...\n" . \
                       $herecurr);
              }
          ...
          sub is_SPDX_License_valid {
              my ($license) = @_;
              ...
              my $status = `cd "$root_path"; echo "$license" |
                            python scripts/spdxcheck.py -`;
              ...
          }
      
      The first chars before 'SPDX-License-Identifier:' are ignored.
      This commit fixes this regression.
      
      Fixes:959b4968 (scripts/spdxcheck.py: Handle special quotation mark comments)
      Signed-off-by: default avatarAurélien Cedeyn <aurelien.cedeyn@gmail.com>
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      a5f4cb42
  11. Feb 20, 2019
    • Masahiro Yamada's avatar
      kbuild: generate modules.order only when CONFIG_MODULES=y · 1d8001ef
      Masahiro Yamada authored
      
      Do not generate pointless modules.order when the module support is
      disabled.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      1d8001ef
    • Masahiro Yamada's avatar
      kbuild: pkg: use -f $(srctree)/Makefile to recurse to top Makefile · 175209cc
      Masahiro Yamada authored
      
      '$(MAKE) KBUILD_SRC=' changes the working directory back and forth
      between objtree and srctree.
      
      It is better to recurse to the top-level Makefile directly.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      175209cc
    • Masahiro Yamada's avatar
      kbuild: Disable extra debugging info in .s output · 1e88e415
      Masahiro Yamada authored
      
      Modern gcc adds view assignments, reset assertion checking in .loc
      directives and a couple more additional debug markers, which clutters
      the asm output unnecessarily:
      
      For example:
      
        bsp_resume:
        .LFB3466:
                .loc 1 1868 1 is_stmt 1 view -0
                .cfi_startproc
                .loc 1 1869 2 view .LVU73
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                .loc 1 1869 14 is_stmt 0 view .LVU74
                movq    this_cpu(%rip), %rax    # this_cpu, this_cpu
                movq    64(%rax), %rax  # this_cpu.94_1->c_bsp_resume, _2
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                .loc 1 1869 5 view .LVU75
                testq   %rax, %rax      # _2
                je      .L8     #,
                .loc 1 1870 3 is_stmt 1 view .LVU76
                movq    $boot_cpu_data, %rdi    #,
                jmp     __x86_indirect_thunk_rax
      
      or
              .loc 2 57 9 view .LVU478
              .loc 2 57 9 view .LVU479
              .loc 2 57 9 view .LVU480
              .loc 2 57 9 view .LVU481
        .LBB1385:
        .LBB1383:
        .LBB1379:
        .LBB1377:
        .LBB1375:
              .loc 2 57 9 view .LVU482
              .loc 2 57 9 view .LVU483
              movl	%edi, %edx	# cpu, cpu
        .LVL87:
              .loc 2 57 9 is_stmt 0 view .LVU484
      
      That MOV in there is drowned in debugging information and latter makes
      it hard to follow the asm. And that DWARF info is not really needed for
      asm output staring.
      
      Disable the debug information generation which clutters the asm output
      unnecessarily:
      
        bsp_resume:
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                movq    this_cpu(%rip), %rax    # this_cpu, this_cpu
                movq    64(%rax), %rax  # this_cpu.94_1->c_bsp_resume, _2
        # arch/x86/kernel/cpu/common.c:1869:    if (this_cpu->c_bsp_resume)
                testq   %rax, %rax      # _2
                je      .L8     #,
        # arch/x86/kernel/cpu/common.c:1870:            this_cpu->c_bsp_resume(&boot_cpu_data);
                movq    $boot_cpu_data, %rdi    #,
                jmp     __x86_indirect_thunk_rax
        .L8:
        # arch/x86/kernel/cpu/common.c:1871: }
                rep ret
                .size   bsp_resume, .-bsp_resume
      
        [ bp: write commit message. ]
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      1e88e415
  12. Feb 19, 2019
    • Arnd Bergmann's avatar
      checksyscalls: fix up mq_timedreceive and stat exceptions · 1d5b8233
      Arnd Bergmann authored
      
      mq_timedreceive was spelled incorrectly, and we need exceptions
      for new architectures that leave out newstat or stat64, implementing
      only statx() now.
      
      Fixes: 48166e6e ("y2038: add 64-bit time_t syscalls to all 32-bit architectures")
      Fixes: bf4b6a7d ("y2038: Remove stat64 family from default syscall set")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      1d5b8233
    • Arnd Bergmann's avatar
      asm-generic: Make time32 syscall numbers optional · c8ce48f0
      Arnd Bergmann authored
      
      We don't want new architectures to even provide the old 32-bit time_t
      based system calls any more, or define the syscall number macros.
      
      Add a new __ARCH_WANT_TIME32_SYSCALLS macro that gets enabled for all
      existing 32-bit architectures using the generic system call table,
      so we don't change any current behavior.
      Since this symbol is evaluated in user space as well, we cannot use
      a Kconfig CONFIG_* macro but have to define it in uapi/asm/unistd.h.
      
      On 64-bit architectures, the same system call numbers mostly refer to
      the system calls we want to keep, as they already pass 64-bit time_t.
      
      As new architectures no longer provide these, we need new exceptions
      in checksyscalls.sh.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      c8ce48f0
    • Masahiro Yamada's avatar
      kallsyms: include <asm/bitsperlong.h> instead of <asm/types.h> · 500193ec
      Masahiro Yamada authored
      
      <asm/bitsperlong.h> is enough to include the definition of
      BITS_PER_LONG.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      500193ec
    • Masahiro Yamada's avatar
      kallsyms: remove unneeded memset() calls · 52a849ed
      Masahiro Yamada authored
      
      Global variables in the .bss section are zeroed out before the program
      starts to run.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      52a849ed
    • Masahiro Yamada's avatar
      kallsyms: add static qualifiers where missing · f43e9daa
      Masahiro Yamada authored
      
      Fix the following sparse warnings:
      
      scripts/kallsyms.c:65:5: warning: symbol 'token_profit' was not declared. Should it be static?
      scripts/kallsyms.c:68:15: warning: symbol 'best_table' was not declared. Should it be static?
      scripts/kallsyms.c:69:15: warning: symbol 'best_table_len' was not declared. Should it be static?
      
      Also, remove 'inline' from is_arm_mapping_symbol(). The compiler
      will inline it anyway when it is appropriate to do so.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      f43e9daa
    • Yury Norov's avatar
      asm-generic: Drop getrlimit and setrlimit syscalls from default list · 80d7da1c
      Yury Norov authored
      
      The newer prlimit64 syscall provides all the functionality of getrlimit
      and setrlimit syscalls and adds the pid of target process, so future
      architectures won't need to include getrlimit and setrlimit.
      
      Therefore drop getrlimit and setrlimit syscalls from the generic syscall
      list unless __ARCH_WANT_SET_GET_RLIMIT is defined by the architecture's
      unistd.h prior to including asm-generic/unistd.h, and adjust all
      architectures using the generic syscall list to define it so that no
      in-tree architectures are affected.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-hexagon@vger.kernel.org
      Cc: uclinux-h8-devel@lists.sourceforge.jp
      Signed-off-by: default avatarYury Norov <ynorov@caviumnetworks.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Acked-by: Mark Salter <msalter@redhat.com> [c6x]
      Acked-by: James Hogan <james.hogan@imgtec.com> [metag]
      Acked-by: Ley Foon Tan <lftan@altera.com> [nios2]
      Acked-by: Stafford Horne <shorne@gmail.com> [openrisc]
      Acked-by: Will Deacon <will.deacon@arm.com> [arm64]
      Acked-by: Vineet Gupta <vgupta@synopsys.com> #arch/arc bits
      Signed-off-by: default avatarYury Norov <ynorov@marvell.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      80d7da1c
Loading