[all-commits] [llvm/llvm-project] d3f893: [KernelAddressSanitizer] Make globals constructors...

Marco Elver via All-commits all-commits at lists.llvm.org
Wed Jun 10 06:09:33 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d3f89314ff20ce1612bd5e09f9f90ff5dd5205a7
      https://github.com/llvm/llvm-project/commit/d3f89314ff20ce1612bd5e09f9f90ff5dd5205a7
  Author: Marco Elver <elver at google.com>
  Date:   2020-06-10 (Wed, 10 Jun 2020)

  Changed paths:
    M clang/test/CodeGen/asan-globals.cpp
    M llvm/include/llvm/Transforms/Utils/ModuleUtils.h
    M llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    M llvm/lib/Transforms/Utils/ModuleUtils.cpp

  Log Message:
  -----------
  [KernelAddressSanitizer] Make globals constructors compatible with kernel [v2]

[ v1 was reverted by c6ec352a6bde1995794c523adc2ebab802ccdf0a due to
  modpost failing; v2 fixes this. More info:
  https://github.com/ClangBuiltLinux/linux/issues/1045#issuecomment-640381783 ]

This makes -fsanitize=kernel-address emit the correct globals
constructors for the kernel. We had to do the following:

* Disable generation of constructors that rely on linker features such
  as dead-global elimination.

* Only instrument globals *not* in explicit sections. The kernel uses
  sections for special globals, which we should not touch.

* Do not instrument globals that are prefixed with "__" nor that are
  aliased by a symbol that is prefixed with "__". For example, modpost
  relies on specially named aliases to find globals and checks their
  contents. Unfortunately modpost relies on size stored as ELF debug info
  and any padding of globals currently causes the debug info to cause size
  reported to be *with* redzone which throws modpost off.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=203493

Tested:
* With 'clang/test/CodeGen/asan-globals.cpp'.

* With test_kasan.ko, we can see:

  	BUG: KASAN: global-out-of-bounds in kasan_global_oob+0xb3/0xba [test_kasan]

* allyesconfig, allmodconfig (x86_64)

Reviewed By: glider

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D81390




More information about the All-commits mailing list