Merge tag 'orphan-handling-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Feb 2021 18:12:19 +0000 (10:12 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Feb 2021 18:12:19 +0000 (10:12 -0800)
Pull orphan handling fix from Kees Cook:
 "Another case of bogus .eh_frame emission was noticed under
  CONFIG_GCOV_KERNEL=y.

  Summary:

   - Define SANITIZER_DISCARDS with CONFIG_GCOV_KERNEL=y (Nathan
     Chancellor)"

* tag 'orphan-handling-v5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  vmlinux.lds.h: Define SANITIZER_DISCARDS with CONFIG_GCOV_KERNEL=y

1  2 
include/asm-generic/vmlinux.lds.h

index 6786f8c0182f11215ab565bf477bc1552218c751,ec89e657ea2f66b4470c68dc7ba0dc248ef3c0db..0331d5d49551a305b92a628f4e20e8f5a7cd72a3
   * .data. We don't want to pull in .data..other sections, which Linux
   * has defined. Same for text and bss.
   *
 + * With LTO_CLANG, the linker also splits sections by default, so we need
 + * these macros to combine the sections during the final link.
 + *
   * RODATA_MAIN is not used because existing code already defines .rodata.x
   * sections to be brought in with rodata.
   */
 -#ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 +#if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
  #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
 -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
 +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L*
  #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 -#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
 -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
 +#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
  #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
  #else
  #define TEXT_MAIN .text
  #define THERMAL_TABLE(name)
  #endif
  
 +#ifdef CONFIG_DTPM
 +#define DTPM_TABLE()                                                  \
 +      . = ALIGN(8);                                                   \
 +      __dtpm_table = .;                                               \
 +      KEEP(*(__dtpm_table))                                           \
 +      __dtpm_table_end = .;
 +#else
 +#define DTPM_TABLE()
 +#endif
 +
  #define KERNEL_DTB()                                                  \
        STRUCT_ALIGN();                                                 \
        __dtb_start = .;                                                \
        . = ALIGN(8);                                                   \
        __start_static_call_sites = .;                                  \
        KEEP(*(.static_call_sites))                                     \
 -      __stop_static_call_sites = .;
 +      __stop_static_call_sites = .;                                   \
 +      __start_static_call_tramp_key = .;                              \
 +      KEEP(*(.static_call_tramp_key))                                 \
 +      __stop_static_call_tramp_key = .;
  
  /*
   * Allow architectures to handle ro_after_init data on their
                __stop___ksymtab_gpl = .;                               \
        }                                                               \
                                                                        \
 -      /* Kernel symbol table: Normal unused symbols */                \
 -      __ksymtab_unused  : AT(ADDR(__ksymtab_unused) - LOAD_OFFSET) {  \
 -              __start___ksymtab_unused = .;                           \
 -              KEEP(*(SORT(___ksymtab_unused+*)))                      \
 -              __stop___ksymtab_unused = .;                            \
 -      }                                                               \
 -                                                                      \
 -      /* Kernel symbol table: GPL-only unused symbols */              \
 -      __ksymtab_unused_gpl : AT(ADDR(__ksymtab_unused_gpl) - LOAD_OFFSET) { \
 -              __start___ksymtab_unused_gpl = .;                       \
 -              KEEP(*(SORT(___ksymtab_unused_gpl+*)))                  \
 -              __stop___ksymtab_unused_gpl = .;                        \
 -      }                                                               \
 -                                                                      \
 -      /* Kernel symbol table: GPL-future-only symbols */              \
 -      __ksymtab_gpl_future : AT(ADDR(__ksymtab_gpl_future) - LOAD_OFFSET) { \
 -              __start___ksymtab_gpl_future = .;                       \
 -              KEEP(*(SORT(___ksymtab_gpl_future+*)))                  \
 -              __stop___ksymtab_gpl_future = .;                        \
 -      }                                                               \
 -                                                                      \
        /* Kernel symbol table: Normal symbols */                       \
        __kcrctab         : AT(ADDR(__kcrctab) - LOAD_OFFSET) {         \
                __start___kcrctab = .;                                  \
                __stop___kcrctab_gpl = .;                               \
        }                                                               \
                                                                        \
 -      /* Kernel symbol table: Normal unused symbols */                \
 -      __kcrctab_unused  : AT(ADDR(__kcrctab_unused) - LOAD_OFFSET) {  \
 -              __start___kcrctab_unused = .;                           \
 -              KEEP(*(SORT(___kcrctab_unused+*)))                      \
 -              __stop___kcrctab_unused = .;                            \
 -      }                                                               \
 -                                                                      \
 -      /* Kernel symbol table: GPL-only unused symbols */              \
 -      __kcrctab_unused_gpl : AT(ADDR(__kcrctab_unused_gpl) - LOAD_OFFSET) { \
 -              __start___kcrctab_unused_gpl = .;                       \
 -              KEEP(*(SORT(___kcrctab_unused_gpl+*)))                  \
 -              __stop___kcrctab_unused_gpl = .;                        \
 -      }                                                               \
 -                                                                      \
 -      /* Kernel symbol table: GPL-future-only symbols */              \
 -      __kcrctab_gpl_future : AT(ADDR(__kcrctab_gpl_future) - LOAD_OFFSET) { \
 -              __start___kcrctab_gpl_future = .;                       \
 -              KEEP(*(SORT(___kcrctab_gpl_future+*)))                  \
 -              __stop___kcrctab_gpl_future = .;                        \
 -      }                                                               \
 -                                                                      \
        /* Kernel symbol table: strings */                              \
          __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) {       \
                *(__ksymtab_strings)                                    \
        ACPI_PROBE_TABLE(irqchip)                                       \
        ACPI_PROBE_TABLE(timer)                                         \
        THERMAL_TABLE(governor)                                         \
 +      DTPM_TABLE()                                                    \
        EARLYCON_TABLE()                                                \
        LSM_TABLE()                                                     \
        EARLY_LSM_TABLE()                                               \
                /* DWARF 4 */                                           \
                .debug_types    0 : { *(.debug_types) }                 \
                /* DWARF 5 */                                           \
 +              .debug_addr     0 : { *(.debug_addr) }                  \
 +              .debug_line_str 0 : { *(.debug_line_str) }              \
 +              .debug_loclists 0 : { *(.debug_loclists) }              \
                .debug_macro    0 : { *(.debug_macro) }                 \
 -              .debug_addr     0 : { *(.debug_addr) }
 +              .debug_names    0 : { *(.debug_names) }                 \
 +              .debug_rnglists 0 : { *(.debug_rnglists) }              \
 +              .debug_str_offsets      0 : { *(.debug_str_offsets) }
  
  /* Stabs debugging sections. */
  #define STABS_DEBUG                                                   \
  #endif
  
  /*
-  * Clang's -fsanitize=kernel-address and -fsanitize=thread produce
-  * unwanted sections (.eh_frame and .init_array.*), but
-  * CONFIG_CONSTRUCTORS wants to keep any .init_array.* sections.
+  * Clang's -fprofile-arcs, -fsanitize=kernel-address, and
+  * -fsanitize=thread produce unwanted sections (.eh_frame
+  * and .init_array.*), but CONFIG_CONSTRUCTORS wants to
+  * keep any .init_array.* sections.
   * https://bugs.llvm.org/show_bug.cgi?id=46478
   */
- #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
+ #if defined(CONFIG_GCOV_KERNEL) || defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN)
  # ifdef CONFIG_CONSTRUCTORS
  #  define SANITIZER_DISCARDS                                          \
        *(.eh_frame)