Page MenuHomePhabricator

[clang-cl][sanitizer] Add -fsanitize-address-use-after-return to clang.
ClosedPublic

Authored by kda on Thu, Jun 10, 4:49 PM.

Details

Summary

Also:

  • add driver test (fsanitize-use-after-return.c)
  • add basic IR test (asan-use-after-return.cpp)
  • (NFC) cleaned up logic for generating table of __asan_stack_malloc depending on flag.

for issue: https://github.com/google/sanitizers/issues/1394

Diff Detail

Event Timeline

kda created this revision.Thu, Jun 10, 4:49 PM
kda requested review of this revision.Thu, Jun 10, 4:49 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptThu, Jun 10, 4:49 PM
kda updated this revision to Diff 351316.Thu, Jun 10, 5:35 PM
  • Change default parameters from Invalid to Never.
vitalybuka accepted this revision.Thu, Jun 10, 10:43 PM

LGTM with some nits and if you extract FunctionStackPoisoner::initializeCallbacks into a separate patch

clang/test/CodeGen/asan-use-after-return.cpp
4

I guess call{{.*}} can be removed from implicit-check-not?

clang/test/Driver/fsanitize-use-after-return.c
18–21

we also want test like this:

// RUN: %clang -target x86_64-apple-macosx10.15-gnu -fsanitize=address \
// RUN:   -fsanitize-address-use-after-return=never -fsanitize-address-use-after-return=always %s -### 2>&1 | \
// RUN:   FileCheck -check-prefix=CHECK-ALWAYS %s
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
105

it's already in llvm:: namespace

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
637

-llvm::

654–656

CL should override argument even if it's default:

maybe at line 643:
UseAfterReturn(ClUseAfterReturn.getNumOccurrences() ? ClUseAfterReturn : UseAfterReturn)

768

drop llvm::

2983–2984

it looks like unrelated patch

2983–2984

could you please fix clang-tidy: warnings

2983–2984

now we insert functions also for Never and Invalid?

This revision is now accepted and ready to land.Thu, Jun 10, 10:43 PM
kda updated this revision to Diff 351505.Fri, Jun 11, 11:06 AM
kda marked 9 inline comments as done.
  • fixed up conflicting command line parameters.
  • only emit asan_stack_malloc calls when needed.
  • trimmed namespace ('llvm').
  • improved tests.
  • Changed default parameters from Never to Runtime.
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
2983–2984

I was trying to only have one loop, since only one thing changes between the two.

This revision was landed with ongoing or failed builds.Fri, Jun 11, 12:07 PM
This revision was automatically updated to reflect the committed changes.
MaskRay added a subscriber: MaskRay.EditedSun, Jun 13, 12:48 PM

Note, clang-cl is an executable for a MSVC compatible compiler driver (ninja clang-cl), so using clang-cl in the subject can cause confusion.