This is an archive of the discontinued LLVM Phabricator instance.

[HWASAN] Implemented LSAN SetLsanTag and IgnoreObjectLocked
ClosedPublic

Authored by kstoimenov on Jan 12 2023, 3:55 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Jan 12 2023, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 3:55 PM
Herald added a subscriber: Enna1. · View Herald Transcript
kstoimenov requested review of this revision.Jan 12 2023, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 3:55 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
kstoimenov retitled this revision from [HWASAN] Implemented LSAN SetLsanTag and FindHeapChunkByAddressFastLocked. to [HWASAN] Implemented LSAN SetLsanTag, FindHeapChunkByAddressFastLocked and IgnoreObjectLocked..Jan 12 2023, 3:58 PM

reinterpret_cast.

After pull.

kstoimenov added inline comments.
compiler-rt/lib/hwasan/hwasan_allocator.cpp
240

This is coped from the ASAN implementation. I think the idea is that if DisabledInThisThread in this thread is true the chunks are marked as ignored.

Moved makefile.

vitalybuka added inline comments.Jan 13 2023, 1:40 PM
compiler-rt/lib/hwasan/hwasan_allocator.cpp
81–82
400

you need Metadata, not a view to edit tags

compiler-rt/lib/hwasan/hwasan_allocator.h
99 ↗(On Diff #489046)

this is View, read only

109 ↗(On Diff #489046)

we don't need it header, make it static in cpp file

Removed FindHeapChunkByAddressFastLocked from header.

kstoimenov marked an inline comment as done.Jan 17 2023, 9:18 AM
kstoimenov added inline comments.
compiler-rt/lib/hwasan/hwasan_allocator.cpp
400

But the Metadata class doesn't have IsAllocated and Beg methods which are needed in PointsIntoChunk for example.

vitalybuka accepted this revision.Jan 17 2023, 5:56 PM
vitalybuka added inline comments.
compiler-rt/lib/asan/asan_allocator.cpp
1097

this needs to be fixed

compiler-rt/lib/hwasan/hwasan_allocator.cpp
400

It's implemented as

bool HwasanChunkView::IsAllocated() const {
  return metadata_ && metadata_->IsAllocated();
}
531–533

this needs to be fixed

537

Same as above

This revision is now accepted and ready to land.Jan 17 2023, 5:56 PM
vitalybuka retitled this revision from [HWASAN] Implemented LSAN SetLsanTag, FindHeapChunkByAddressFastLocked and IgnoreObjectLocked. to [HWASAN] Implemented LSAN SetLsanTag and IgnoreObjectLocked.Jan 17 2023, 5:57 PM
This revision was landed with ongoing or failed builds.Jan 17 2023, 5:59 PM
This revision was automatically updated to reflect the committed changes.

Hi, it looks like this change broke the Fuchsia toolchain build with an undefined symbol reference. Would you mind fixing this forward if it's easy enough, and reverting otherwise?

https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=120168

FAILED: /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/16/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so 
ld.lld: error: undefined symbol: __lsan::UseExitcodeOnLeak()
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__lsan::ExitHook(int))
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__sanitizer_process_exit_hook)
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

Hi, it looks like this change broke the Fuchsia toolchain build with an undefined symbol reference. Would you mind fixing this forward if it's easy enough, and reverting otherwise?

https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=120168

FAILED: /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/16/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so 
ld.lld: error: undefined symbol: __lsan::UseExitcodeOnLeak()
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__lsan::ExitHook(int))
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__sanitizer_process_exit_hook)
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

@kstoimenov
hwasan needs similar to asans bool UseExitcodeOnLeak() { return __asan::flags()->halt_on_error; }

kstoimenov added a comment.EditedJan 18 2023, 2:04 PM

Hi, it looks like this change broke the Fuchsia toolchain build with an undefined symbol reference. Would you mind fixing this forward if it's easy enough, and reverting otherwise?

https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=120168

FAILED: /opt/s/w/ir/x/w/staging/llvm_build/lib/clang/16/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so 
ld.lld: error: undefined symbol: __lsan::UseExitcodeOnLeak()
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__lsan::ExitHook(int))
>>> referenced by lsan_common_fuchsia.cpp:61 (../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp:61)
>>>               compiler-rt/lib/lsan/CMakeFiles/RTLSanCommon.x86_64.dir/lsan_common_fuchsia.cpp.obj:(__sanitizer_process_exit_hook)
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)

Correction: D142057 should fix that.