Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Dec 19, 2021
  2. Dec 12, 2021
  3. Dec 08, 2021
  4. Dec 06, 2021
  5. Dec 05, 2021
  6. Nov 28, 2021
  7. Nov 21, 2021
  8. Nov 14, 2021
  9. Nov 06, 2021
    • Kees Cook's avatar
      Compiler Attributes: add __alloc_size() for better bounds checking · 86cffecd
      Kees Cook authored
      GCC and Clang can use the "alloc_size" attribute to better inform the
      results of __builtin_object_size() (for compile-time constant values).
      Clang can additionally use alloc_size to inform the results of
      __builtin_dynamic_object_size() (for run-time values).
      
      Because GCC sees the frequent use of struct_size() as an allocator size
      argument, and notices it can return SIZE_MAX (the overflow indication),
      it complains about these call sites overflowing (since SIZE_MAX is
      greater than the default -Walloc-size-larger-than=PTRDIFF_MAX).  This
      isn't helpful since we already know a SIZE_MAX will be caught at
      run-time (this was an intentional design).  To deal with this, we must
      disable this check as it is both a false positive and redundant.  (Clang
      does not have this warning option.)
      
      Unfortunately, just checking the -Wno-alloc-size-larger-than is not
      sufficient to make the __alloc_size attribute behave correctly under
      older GCC versions.  The attribute itself must be disabled in those
      situations too, as there appears to be no way to reliably silence the
      SIZE_MAX constant expression cases for GCC versions less than 9.1:
      
         In file included from ./include/linux/resource_ext.h:11,
                          from ./include/linux/pci.h:40,
                          from drivers/net/ethernet/intel/ixgbe/ixgbe.h:9,
                          from drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c:4:
         In function 'kmalloc_node',
             inlined from 'ixgbe_alloc_q_vector' at ./include/linux/slab.h:743:9:
         ./include/linux/slab.h:618:9: error: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
           return __kmalloc_node(size, flags, node);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         ./include/linux/slab.h: In function 'ixgbe_alloc_q_vector':
         ./include/linux/slab.h:455:7: note: in a call to allocation function '__kmalloc_node' declared here
          void *__kmalloc_node(size_t size, gfp_t flags, int node) __assume_slab_alignment __malloc;
                ^~~~~~~~~~~~~~
      
      Specifically:
       '-Wno-alloc-size-larger-than' is not correctly handled by GCC < 9.1
          https://godbolt.org/z/hqsfG7q84 (doesn't disable)
          https://godbolt.org/z/P9jdrPTYh (doesn't admit to not knowing about option)
          https://godbolt.org/z/465TPMWKb (only warns when other warnings appear)
      
       '-Walloc-size-larger-than=18446744073709551615' is not handled by GCC < 8.2
          https://godbolt.org/z/73hh1EPxz (ignores numeric value)
      
      Since anything marked with __alloc_size would also qualify for marking
      with __malloc, just include __malloc along with it to avoid redundant
      markings.  (Suggested by Linus Torvalds.)
      
      Finally, make sure checkpatch.pl doesn't get confused about finding the
      __alloc_size attribute on functions.  (Thanks to Joe Perches.)
      
      Link: https://lkml.kernel.org/r/20210930222704.2631604-3-keescook@chromium.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Andy Whitcroft <apw@canonical.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Daniel Micay <danielmicay@gmail.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dennis Zhou <dennis@kernel.org>
      Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Alexandre Bounine <alex.bou9@gmail.com>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jing Xiangfeng <jingxiangfeng@huawei.com>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: Matt Porter <mporter@kernel.crashing.org>
      Cc: Miguel Ojeda <ojeda@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Souptick Joarder <jrdr.linux@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      86cffecd
  10. Nov 01, 2021
  11. Oct 31, 2021
  12. Oct 25, 2021
  13. Oct 24, 2021
  14. Oct 18, 2021
  15. Oct 10, 2021
  16. Oct 03, 2021
  17. Sep 26, 2021
  18. Sep 25, 2021
  19. Sep 21, 2021
    • Alexey Dobriyan's avatar
      isystem: delete global -isystem compile option · 04e85bbf
      Alexey Dobriyan authored
      Further isolate kernel from userspace, prevent accidental inclusion of
      undesireable headers, mainly float.h and stdatomic.h.
      
      nds32 keeps -isystem globally due to intrinsics used in entrenched header.
      
      -isystem is selectively reenabled for some files, again, for intrinsics.
      
      Compile tested on:
      
      hexagon-defconfig hexagon-allmodconfig
      alpha-allmodconfig alpha-allnoconfig alpha-defconfig arm64-allmodconfig
      arm64-allnoconfig arm64-defconfig arm-am200epdkit arm-aspeed_g4
      arm-aspeed_g5 arm-assabet arm-at91_dt arm-axm55xx arm-badge4 arm-bcm2835
      arm-cerfcube arm-clps711x arm-cm_x300 arm-cns3420vb arm-colibri_pxa270
      arm-colibri_pxa300 arm-collie arm-corgi arm-davinci_all arm-dove
      arm-ep93xx arm-eseries_pxa arm-exynos arm-ezx arm-footbridge arm-gemini
      arm-h3600 arm-h5000 arm-hackkit arm-hisi arm-imote2 arm-imx_v4_v5
      arm-imx_v6_v7 arm-integrator arm-iop32x arm-ixp4xx arm-jornada720
      arm-keystone arm-lart arm-lpc18xx arm-lpc32xx arm-lpd270 arm-lubbock
      arm-magician arm-mai...
      04e85bbf
  20. Sep 19, 2021
  21. Sep 13, 2021
  22. Sep 12, 2021
  23. Sep 08, 2021
  24. Sep 05, 2021
    • Linus Torvalds's avatar
      Enable '-Werror' by default for all kernel builds · 3fe617cc
      Linus Torvalds authored
      
      ... but make it a config option so that broken environments can disable
      it when required.
      
      We really should always have a clean build, and will disable specific
      over-eager warnings as required, if we can't fix them.  But while I
      fairly religiously enforce that in my own tree, it doesn't get enforced
      by various build robots that don't necessarily report warnings.
      
      So this just makes '-Werror' a default compiler flag, but allows people
      to disable it for their configuration if they have some particular
      issues.
      
      Occasionally, new compiler versions end up enabling new warnings, and it
      can take a while before we have them fixed (or the warnings disabled if
      that is what it takes), so the config option allows for that situation.
      
      Hopefully this will mean that I get fewer pull requests that have new
      warnings that were not noticed by various automation we have in place.
      
      Knock wood.
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3fe617cc
  25. Sep 02, 2021
    • Nathan Chancellor's avatar
      kbuild: Shuffle blank line to improve comment meaning · 6272cc38
      Nathan Chancellor authored
      
      -Wunused-but-set-variable and -Wunused-const-variable are both disabled
      for the same reason but there is a blank line between them and no blank
      line between -Wno-unused-const-variable and the block.
      
      Shuffle the new line so that it is clear that the comment applied to
      both flags and the next block is separate from them.
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      6272cc38
    • Nathan Chancellor's avatar
      kbuild: Add a comment above -Wno-gnu · 5c6ae0ef
      Nathan Chancellor authored
      
      Whenever a warning is disabled, it is helpful for future travelers to
      understand why the warning is disabled and why it is acceptable to do
      so. Add a comment for -Wno-gnu so that people understand why it is
      disabled.
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5c6ae0ef
    • Nathan Chancellor's avatar
      kbuild: Remove -Wno-format-invalid-specifier from clang block · a312b60d
      Nathan Chancellor authored
      Turning on -Wformat does not reveal any instances of this warning across
      several different builds so remove this line to keep the number of
      disabled warnings as slim as possible.
      
      This has been disabled since commit 61163efa
      
       ("kbuild: LLVMLinux:
      Add Kbuild support for building kernel with Clang"), which does not
      explain exactly why it was turned off but since it was so long ago in
      terms of both the kernel and LLVM so it is possible that some bug got
      fixed along the way.
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a312b60d
    • Nick Desaulniers's avatar
      Makefile: remove stale cc-option checks · 7d73c3e9
      Nick Desaulniers authored
      cc-option, cc-option-yn, and cc-disable-warning all invoke the compiler
      during build time, and can slow down the build when these checks become
      stale for our supported compilers, whose minimally supported versions
      increases over time. See Documentation/process/changes.rst for the
      current supported minimal versions (GCC 4.9+, clang 10.0.1+). Compiler
      version support for these flags may be verified on godbolt.org.
      
      The following flags are GCC only and supported since at least GCC 4.9.
      Remove cc-option and cc-disable-warning tests.
      * -fno-tree-loop-im
      * -Wno-maybe-uninitialized
      * -fno-reorder-blocks
      * -fno-ipa-cp-clone
      * -fno-partial-inlining
      * -femit-struct-debug-baseonly
      * -fno-inline-functions-called-once
      * -fconserve-stack
      
      The following flags are supported by all supported versions of GCC and
      Clang. Remove their cc-option, cc-option-yn, and cc-disable-warning tests.
      * -fno-delete-null-pointer-checks
      * -fno-var-tracking
      * -Wno-array-bounds
      
      The following configs are made dependent on GCC, since they use GCC
      specific flags.
      * READABLE_ASM
      * DEBUG_SECTION_MISMATCH
      
      -mfentry was not supported by s390-linux-gnu-gcc until gcc-9+, add a
      comment.
      
      --param=allow-store-data-races=0 was renamed to -fno-allow-store-data-races
      in the GCC 10 release; add a comment.
      
      -Wmaybe-uninitialized (GCC specific) was being added for CONFIG_GCOV,
      then again unconditionally; add it only once.
      
      Also, base RETPOLINE_CFLAGS and RETPOLINE_VDSO_CFLAGS on CONFIC_CC_IS_*
      then remove cc-option tests for Clang.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1436
      
      
      Acked-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      7d73c3e9
  26. Sep 01, 2021
  27. Aug 29, 2021
  28. Aug 22, 2021
  29. Aug 15, 2021
  30. Aug 09, 2021
  31. Aug 08, 2021