[PATCH] D80805: [KernelAddressSanitizer] Make globals constructors compatible with kernel

Marco Elver via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 29 08:40:01 PDT 2020


melver created this revision.
melver added reviewers: glider, andreyknvl.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
melver edited the summary of this revision.
melver updated this revision to Diff 267253.
melver added a comment.

Add missing comment.


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 emit constructors for globals *not* in explicit sections. The kernel uses sections for special globals, which we should not touch.

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

Tested:

  With test_kasan.ko, we can see the line
  
  	BUG: KASAN: global-out-of-bounds in kasan_global_oob+0xb3/0xba [test_kasan]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80805

Files:
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Utils/ModuleUtils.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80805.267253.patch
Type: text/x-patch
Size: 7055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200529/4ac213ef/attachment-0001.bin>


More information about the llvm-commits mailing list