[PATCH] D92078: [asan] Default to -asan-use-private-alias=1

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 25 00:19:26 PST 2020


MaskRay created this revision.
MaskRay added reviewers: eugenis, rnk, rsmith, vitalybuka.
Herald added subscribers: llvm-commits, Sanitizers, hiraditya.
Herald added projects: Sanitizers, LLVM.
MaskRay requested review of this revision.

Pros: the following issues are fixed

- Bogus `The following global variable is not properly aligned.` error for interposed global variables.

(PR37545 (this patch should allow us to restore D46665 <https://reviews.llvm.org/D46665>) and https://github.com/google/sanitizers/issues/1017)

Global variables of non-`hasExactDefinition()` linkages (i.e.
linkonce/linkonce_odr/weak/weak_odr/common/external_weak) are not instrumented.
If an instrumented variable gets interposed to an uninstrumented variable due to symbol
interposition (e.g. in PR37545, _ZTS1A in foo.so is resolved to _ZTS1A in the
executable), there may be a bogus error.

With private aliases, the register code will not resolve to a definition in another module,
and thus prevent the issue.

Note that GCC also uses private aliases.

- https://github.com/google/sanitizers/issues/398

Similar to the above, but about an instrumented global variable gets interposed
to an uninstrumented global variable (not using address sanitizer) in another
module.

Cons:

- Some ODR issues due to interposition are no longer detectable.

e.g. odr_c_test.c

- Can't catch overflows in globals relocated by `R_*_COPY`

(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68016)
This affects -fno-pic and -fpie -mpie-copy-relocations.
However, -fpie (without -mpie-copy-relocations) produced code can still
catch the overflow.

  // foo.so
  int f[5] = {1};
  // a.out
  extern int f[5]; int main() { return f[5]; }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92078

Files:
  compiler-rt/test/asan/TestCases/Linux/odr-violation.cpp
  compiler-rt/test/asan/TestCases/Linux/odr-vtable.cpp
  compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll
  llvm/test/Instrumentation/AddressSanitizer/odr-check-ignore.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92078.307526.patch
Type: text/x-patch
Size: 10841 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201125/eb0974b3/attachment.bin>


More information about the llvm-commits mailing list