Merge tag 'hardening-v6.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Nov 2022 19:41:02 +0000 (11:41 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 11 Nov 2022 19:41:02 +0000 (11:41 -0800)
Pull kernel hardening fix from Kees Cook:

 - Fix !SMP placement of '.data..decrypted' section (Nathan Chancellor)

* tag 'hardening-v6.1-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  vmlinux.lds.h: Fix placement of '.data..decrypted' section

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

  #define PATCHABLE_DISCARDS    *(__patchable_function_entries)
  #endif
  
 +#ifndef CONFIG_ARCH_SUPPORTS_CFI_CLANG
 +/*
 + * Simply points to ftrace_stub, but with the proper protocol.
 + * Defined by the linker script in linux/vmlinux.lds.h
 + */
 +#define       FTRACE_STUB_HACK        ftrace_stub_graph = ftrace_stub;
 +#else
 +#define FTRACE_STUB_HACK
 +#endif
 +
  #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  /*
   * The ftrace call sites are logged to a section whose name depends on the
   * FTRACE_CALLSITE_SECTION. We capture all of them here to avoid header
   * dependencies for FTRACE_CALLSITE_SECTION's definition.
   *
 - * Need to also make ftrace_stub_graph point to ftrace_stub
 - * so that the same stub location may have different protocols
 - * and not mess up with C verifiers.
 - *
   * ftrace_ops_list_func will be defined as arch_ftrace_ops_list_func
   * as some archs will have a different prototype for that function
   * but ftrace_ops_list_func() will have a single prototype.
                        KEEP(*(__mcount_loc))                   \
                        KEEP_PATCHABLE                          \
                        __stop_mcount_loc = .;                  \
 -                      ftrace_stub_graph = ftrace_stub;        \
 +                      FTRACE_STUB_HACK                        \
                        ftrace_ops_list_func = arch_ftrace_ops_list_func;
  #else
  # ifdef CONFIG_FUNCTION_TRACER
 -#  define MCOUNT_REC()        ftrace_stub_graph = ftrace_stub;        \
 +#  define MCOUNT_REC()        FTRACE_STUB_HACK                        \
                        ftrace_ops_list_func = arch_ftrace_ops_list_func;
  # else
  #  define MCOUNT_REC()
  #define DATA_DATA                                                     \
        *(.xiptext)                                                     \
        *(DATA_MAIN)                                                    \
+       *(.data..decrypted)                                             \
        *(.ref.data)                                                    \
        *(.data..shared_aligned) /* percpu related */                   \
        MEM_KEEP(init.data*)                                            \
  #ifdef CONFIG_AMD_MEM_ENCRYPT
  #define PERCPU_DECRYPTED_SECTION                                      \
        . = ALIGN(PAGE_SIZE);                                           \
-       *(.data..decrypted)                                             \
        *(.data..percpu..decrypted)                                     \
        . = ALIGN(PAGE_SIZE);
  #else