1. 03 6月, 2021 1 次提交
    • N
      vmlinux.lds.h: Avoid orphan section with !SMP · d4c63999
      Nathan Chancellor 提交于
      With x86_64_defconfig and the following configs, there is an orphan
      section warning:
      
      CONFIG_SMP=n
      CONFIG_AMD_MEM_ENCRYPT=y
      CONFIG_HYPERVISOR_GUEST=y
      CONFIG_KVM=y
      CONFIG_PARAVIRT=y
      
      ld: warning: orphan section `.data..decrypted' from `arch/x86/kernel/cpu/vmware.o' being placed in section `.data..decrypted'
      ld: warning: orphan section `.data..decrypted' from `arch/x86/kernel/kvm.o' being placed in section `.data..decrypted'
      
      These sections are created with DEFINE_PER_CPU_DECRYPTED, which
      ultimately turns into __PCPU_ATTRS, which in turn has a section
      attribute with a value of PER_CPU_BASE_SECTION + the section name. When
      CONFIG_SMP is not set, the base section is .data and that is not
      currently handled in any linker script.
      
      Add .data..decrypted to PERCPU_DECRYPTED_SECTION, which is included in
      PERCPU_INPUT -> PERCPU_SECTION, which is include in the x86 linker
      script when either CONFIG_X86_64 or CONFIG_SMP is unset, taking care of
      the warning.
      
      Fixes: ac26963a ("percpu: Introduce DEFINE_PER_CPU_DECRYPTED")
      Link: https://github.com/ClangBuiltLinux/linux/issues/1360Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NNathan Chancellor <nathan@kernel.org>
      Tested-by: Nick Desaulniers <ndesaulniers@google.com> # build
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20210506001410.1026691-1-nathan@kernel.org
      d4c63999
  2. 09 4月, 2021 1 次提交
    • S
      add support for Clang CFI · cf68fffb
      Sami Tolvanen 提交于
      This change adds support for Clang’s forward-edge Control Flow
      Integrity (CFI) checking. With CONFIG_CFI_CLANG, the compiler
      injects a runtime check before each indirect function call to ensure
      the target is a valid function with the correct static type. This
      restricts possible call targets and makes it more difficult for
      an attacker to exploit bugs that allow the modification of stored
      function pointers. For more details, see:
      
        https://clang.llvm.org/docs/ControlFlowIntegrity.html
      
      Clang requires CONFIG_LTO_CLANG to be enabled with CFI to gain
      visibility to possible call targets. Kernel modules are supported
      with Clang’s cross-DSO CFI mode, which allows checking between
      independently compiled components.
      
      With CFI enabled, the compiler injects a __cfi_check() function into
      the kernel and each module for validating local call targets. For
      cross-module calls that cannot be validated locally, the compiler
      calls the global __cfi_slowpath_diag() function, which determines
      the target module and calls the correct __cfi_check() function. This
      patch includes a slowpath implementation that uses __module_address()
      to resolve call targets, and with CONFIG_CFI_CLANG_SHADOW enabled, a
      shadow map that speeds up module look-ups by ~3x.
      
      Clang implements indirect call checking using jump tables and
      offers two methods of generating them. With canonical jump tables,
      the compiler renames each address-taken function to <function>.cfi
      and points the original symbol to a jump table entry, which passes
      __cfi_check() validation. This isn’t compatible with stand-alone
      assembly code, which the compiler doesn’t instrument, and would
      result in indirect calls to assembly code to fail. Therefore, we
      default to using non-canonical jump tables instead, where the compiler
      generates a local jump table entry <function>.cfi_jt for each
      address-taken function, and replaces all references to the function
      with the address of the jump table entry.
      
      Note that because non-canonical jump table addresses are local
      to each component, they break cross-module function address
      equality. Specifically, the address of a global function will be
      different in each module, as it's replaced with the address of a local
      jump table entry. If this address is passed to a different module,
      it won’t match the address of the same function taken there. This
      may break code that relies on comparing addresses passed from other
      components.
      
      CFI checking can be disabled in a function with the __nocfi attribute.
      Additionally, CFI can be disabled for an entire compilation unit by
      filtering out CC_FLAGS_CFI.
      
      By default, CFI failures result in a kernel panic to stop a potential
      exploit. CONFIG_CFI_PERMISSIVE enables a permissive mode, where the
      kernel prints out a rate-limited warning instead, and allows execution
      to continue. This option is helpful for locating type mismatches, but
      should only be enabled during development.
      Signed-off-by: NSami Tolvanen <samitolvanen@google.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Tested-by: NNathan Chancellor <nathan@kernel.org>
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20210408182843.1754385-2-samitolvanen@google.com
      cf68fffb
  3. 26 2月, 2021 1 次提交
  4. 23 2月, 2021 1 次提交
    • A
      vmlinux.lds.h: catch even more instrumentation symbols into .data · 49387f62
      Alexander Lobakin 提交于
      LKP caught another bunch of orphaned instrumentation symbols [0]:
      
      mipsel-linux-ld: warning: orphan section `.data.$LPBX1' from
      `init/main.o' being placed in section `.data.$LPBX1'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX0' from
      `init/main.o' being placed in section `.data.$LPBX0'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX1' from
      `init/do_mounts.o' being placed in section `.data.$LPBX1'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX0' from
      `init/do_mounts.o' being placed in section `.data.$LPBX0'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX1' from
      `init/do_mounts_initrd.o' being placed in section `.data.$LPBX1'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX0' from
      `init/do_mounts_initrd.o' being placed in section `.data.$LPBX0'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX1' from
      `init/initramfs.o' being placed in section `.data.$LPBX1'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX0' from
      `init/initramfs.o' being placed in section `.data.$LPBX0'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX1' from
      `init/calibrate.o' being placed in section `.data.$LPBX1'
      mipsel-linux-ld: warning: orphan section `.data.$LPBX0' from
      `init/calibrate.o' being placed in section `.data.$LPBX0'
      
      [...]
      
      Soften the wildcard to .data.$L* to grab these ones into .data too.
      
      [0] https://lore.kernel.org/lkml/202102231519.lWPLPveV-lkp@intel.comReported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NAlexander Lobakin <alobakin@pm.me>
      Signed-off-by: NThomas Bogendoerfer <tsbogend@alpha.franken.de>
      49387f62
  5. 17 2月, 2021 2 次提交
  6. 16 2月, 2021 1 次提交
  7. 10 2月, 2021 1 次提交
  8. 08 2月, 2021 2 次提交
  9. 15 1月, 2021 3 次提交
  10. 23 12月, 2020 1 次提交
    • D
      powercap/drivers/dtpm: Add API for dynamic thermal power management · a20d0ef9
      Daniel Lezcano 提交于
      On the embedded world, the complexity of the SoC leads to an
      increasing number of hotspots which need to be monitored and mitigated
      as a whole in order to prevent the temperature to go above the
      normative and legally stated 'skin temperature'.
      
      Another aspect is to sustain the performance for a given power budget,
      for example virtual reality where the user can feel dizziness if the
      GPU performance is capped while a big CPU is processing something
      else. Or reduce the battery charging because the dissipated power is
      too high compared with the power consumed by other devices.
      
      The userspace is the most adequate place to dynamically act on the
      different devices by limiting their power given an application
      profile: it has the knowledge of the platform.
      
      These userspace daemons are in charge of the Dynamic Thermal Power
      Management (DTPM).
      
      Nowadays, the dtpm daemons are abusing the thermal framework as they
      act on the cooling device state to force a specific and arbitrary
      state without taking care of the governor decisions. Given the closed
      loop of some governors that can confuse the logic or directly enter in
      a decision conflict.
      
      As the number of cooling device support is limited today to the CPU
      and the GPU, the dtpm daemons have little control on the power
      dissipation of the system. The out of tree solutions are hacking
      around here and there in the drivers, in the frameworks to have
      control on the devices. The common solution is to declare them as
      cooling devices.
      
      There is no unification of the power limitation unit, opaque states
      are used.
      
      This patch provides a way to create a hierarchy of constraints using
      the powercap framework. The devices which are registered as power
      limit-able devices are represented in this hierarchy as a tree. They
      are linked together with intermediate nodes which are just there to
      propagate the constraint to the children.
      
      The leaves of the tree are the real devices, the intermediate nodes
      are virtual, aggregating the children constraints and power
      characteristics.
      
      Each node have a weight on a 2^10 basis, in order to reflect the
      percentage of power distribution of the children's node. This
      percentage is used to dispatch the power limit to the children.
      
      The weight is computed against the max power of the siblings.
      
      This simple approach allows to do a fair distribution of the power
      limit.
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Reviewed-by: NLukasz Luba <lukasz.luba@arm.com>
      Tested-by: NLukasz Luba <lukasz.luba@arm.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a20d0ef9
  11. 28 10月, 2020 1 次提交
  12. 10 10月, 2020 1 次提交
  13. 22 9月, 2020 1 次提交
  14. 01 9月, 2020 8 次提交
  15. 15 8月, 2020 1 次提交
  16. 24 7月, 2020 1 次提交
  17. 22 7月, 2020 1 次提交
    • J
      x86, vmlinux.lds: Page-align end of ..page_aligned sections · de2b41be
      Joerg Roedel 提交于
      On x86-32 the idt_table with 256 entries needs only 2048 bytes. It is
      page-aligned, but the end of the .bss..page_aligned section is not
      guaranteed to be page-aligned.
      
      As a result, objects from other .bss sections may end up on the same 4k
      page as the idt_table, and will accidentially get mapped read-only during
      boot, causing unexpected page-faults when the kernel writes to them.
      
      This could be worked around by making the objects in the page aligned
      sections page sized, but that's wrong.
      
      Explicit sections which store only page aligned objects have an implicit
      guarantee that the object is alone in the page in which it is placed. That
      works for all objects except the last one. That's inconsistent.
      
      Enforcing page sized objects for these sections would wreckage memory
      sanitizers, because the object becomes artificially larger than it should
      be and out of bound access becomes legit.
      
      Align the end of the .bss..page_aligned and .data..page_aligned section on
      page-size so all objects places in these sections are guaranteed to have
      their own page.
      
      [ tglx: Amended changelog ]
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200721093448.10417-1-joro@8bytes.org
      de2b41be
  18. 14 7月, 2020 1 次提交
  19. 08 7月, 2020 1 次提交
  20. 25 6月, 2020 2 次提交
  21. 19 5月, 2020 1 次提交
  22. 27 3月, 2020 1 次提交
  23. 19 3月, 2020 1 次提交
  24. 19 11月, 2019 1 次提交
    • S
      ftrace: Rename ftrace_graph_stub to ftrace_stub_graph · 46f94692
      Steven Rostedt (VMware) 提交于
      The ftrace_graph_stub was created and points to ftrace_stub as a way to
      assign the functon graph tracer function pointer to a stub function with a
      different prototype than what ftrace_stub has and not trigger the C
      verifier. The ftrace_graph_stub was created via the linker script
      vmlinux.lds.h. Unfortunately, powerpc already uses the name
      ftrace_graph_stub for its internal implementation of the function graph
      tracer, and even though powerpc would still build, the change via the linker
      script broke function tracer on powerpc from working.
      
      By using the name ftrace_stub_graph, which does not exist anywhere else in
      the kernel, this should not be a problem.
      
      Link: https://lore.kernel.org/r/1573849732.5937.136.camel@lca.pw
      
      Fixes: b83b43ff ("fgraph: Fix function type mismatches of ftrace_graph_return using ftrace_stub")
      Reorted-by: NQian Cai <cai@lca.pw>
      Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      46f94692
  25. 15 11月, 2019 1 次提交
  26. 06 11月, 2019 1 次提交
    • M
      module/ftrace: handle patchable-function-entry · a1326b17
      Mark Rutland 提交于
      When using patchable-function-entry, the compiler will record the
      callsites into a section named "__patchable_function_entries" rather
      than "__mcount_loc". Let's abstract this difference behind a new
      FTRACE_CALLSITE_SECTION, so that architectures don't have to handle this
      explicitly (e.g. with custom module linker scripts).
      
      As parisc currently handles this explicitly, it is fixed up accordingly,
      with its custom linker script removed. Since FTRACE_CALLSITE_SECTION is
      only defined when DYNAMIC_FTRACE is selected, the parisc module loading
      code is updated to only use the definition in that case. When
      DYNAMIC_FTRACE is not selected, modules shouldn't have this section, so
      this removes some redundant work in that case.
      
      To make sure that this is keep up-to-date for modules and the main
      kernel, a comment is added to vmlinux.lds.h, with the existing ifdeffery
      simplified for legibility.
      
      I built parisc generic-{32,64}bit_defconfig with DYNAMIC_FTRACE enabled,
      and verified that the section made it into the .ko files for modules.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NHelge Deller <deller@gmx.de>
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reviewed-by: NTorsten Duwe <duwe@suse.de>
      Tested-by: NAmit Daniel Kachhap <amit.kachhap@arm.com>
      Tested-by: NSven Schnelle <svens@stackframe.org>
      Tested-by: NTorsten Duwe <duwe@suse.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Jessica Yu <jeyu@kernel.org>
      Cc: linux-parisc@vger.kernel.org
      a1326b17
  27. 04 11月, 2019 2 次提交
    • K
      vmlinux.lds.h: Allow EXCEPTION_TABLE to live in RO_DATA · b8c2f776
      Kees Cook 提交于
      Many architectures have an EXCEPTION_TABLE that needs to be only
      readable. As such, it should live in RO_DATA. Create a macro to identify
      this case for the architectures that can move EXCEPTION_TABLE into
      RO_DATA.
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NWill Deacon <will@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: linux-alpha@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-c6x-dev@linux-c6x.org
      Cc: linux-ia64@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-s390@vger.kernel.org
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
      Cc: Segher Boessenkool <segher@kernel.crashing.org>
      Cc: x86-ml <x86@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20191029211351.13243-15-keescook@chromium.org
      b8c2f776
    • K
      vmlinux.lds.h: Replace RW_DATA_SECTION with RW_DATA · c9174047
      Kees Cook 提交于
      Rename RW_DATA_SECTION to RW_DATA. (Calling this a "section" is a lie,
      since it's multiple sections and section flags cannot be applied to
      the macro.)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> # s390
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: linux-alpha@vger.kernel.org
      Cc: linux-arch@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-c6x-dev@linux-c6x.org
      Cc: linux-ia64@vger.kernel.org
      Cc: linux-s390@vger.kernel.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Rick Edgecombe <rick.p.edgecombe@intel.com>
      Cc: Segher Boessenkool <segher@kernel.crashing.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: x86-ml <x86@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Link: https://lkml.kernel.org/r/20191029211351.13243-14-keescook@chromium.org
      c9174047