Merge tag 'hardening-v5.18-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 31 Mar 2022 18:43:01 +0000 (11:43 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 31 Mar 2022 18:43:01 +0000 (11:43 -0700)
Pull hardening updates from Kees Cook:
 "This addresses an -Warray-bounds warning found under a few ARM
  defconfigs, and disables long-broken HARDENED_USERCOPY_PAGESPAN"

* tag 'hardening-v5.18-rc1-fix1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  ARM/dma-mapping: Remove CMA code when not built with CMA
  usercopy: Disable CONFIG_HARDENED_USERCOPY_PAGESPAN

1  2 
include/linux/cma.h
security/Kconfig

diff --combined include/linux/cma.h
   */
  #ifdef CONFIG_CMA_AREAS
  #define MAX_CMA_AREAS (1 + CONFIG_CMA_AREAS)
- #else
- #define MAX_CMA_AREAS (0)
  #endif
  
  #define CMA_MAX_NAME 64
  
 +/*
 + * TODO: once the buddy -- especially pageblock merging and alloc_contig_range()
 + * -- can deal with only some pageblocks of a higher-order page being
 + *  MIGRATE_CMA, we can use pageblock_nr_pages.
 + */
 +#define CMA_MIN_ALIGNMENT_PAGES MAX_ORDER_NR_PAGES
 +#define CMA_MIN_ALIGNMENT_BYTES (PAGE_SIZE * CMA_MIN_ALIGNMENT_PAGES)
 +
  struct cma;
  
  extern unsigned long totalcma_pages;
@@@ -58,6 -46,4 +54,6 @@@ extern bool cma_pages_valid(struct cma 
  extern bool cma_release(struct cma *cma, const struct page *pages, unsigned long count);
  
  extern int cma_for_each_area(int (*it)(struct cma *cma, void *data), void *data);
 +
 +extern void cma_reserve_pages_on_error(struct cma *cma);
  #endif
diff --combined security/Kconfig
@@@ -166,7 -166,7 +166,7 @@@ config HARDENED_USERCOP
  config HARDENED_USERCOPY_PAGESPAN
        bool "Refuse to copy allocations that span multiple pages"
        depends on HARDENED_USERCOPY
-       depends on EXPERT
+       depends on BROKEN
        help
          When a multi-page allocation is done without __GFP_COMP,
          hardened usercopy will reject attempts to copy it. There are,
  config FORTIFY_SOURCE
        bool "Harden common str/mem functions against buffer overflows"
        depends on ARCH_HAS_FORTIFY_SOURCE
 -      # https://bugs.llvm.org/show_bug.cgi?id=50322
        # https://bugs.llvm.org/show_bug.cgi?id=41459
 -      depends on !CC_IS_CLANG
 +      depends on !CC_IS_CLANG || CLANG_VERSION >= 120001
 +      # https://github.com/llvm/llvm-project/issues/53645
 +      depends on !CC_IS_CLANG || !X86_32
        help
          Detect overflows of buffers in common string and memory functions
          where the compiler can determine and validate the buffer sizes.