This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] add interceptor for dlopen, check if user dlopens shared library with RTLD_DEEPBIND flag
AbandonedPublic

Authored by Enna1 on Apr 24 2023, 4:40 AM.

Details

Summary

Checking if user dlopens shared library with RTLD_DEEPBIND flag is implemented in sanitizer_common_interceptors.inc, and HWASAN doesn't include sanitizer_common_interceptors.inc.
This patch adds dlopen interceptor and checks if dlopen is called with RTLD_DEEPBIND flag for HWASAN.

Diff Detail

Event Timeline

Enna1 created this revision.Apr 24 2023, 4:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 4:40 AM
Herald added a subscriber: krytarowski. · View Herald Transcript
Enna1 published this revision for review.Apr 24 2023, 4:50 AM
Enna1 edited the summary of this revision. (Show Details)
Enna1 added reviewers: vitalybuka, eugenis.
Enna1 added a subscriber: MTC.
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 4:51 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

How important this is now?
We are likely will need sanitizer_common_interceptors.inc. So I'd rather wait for that.

compiler-rt/lib/hwasan/hwasan_interceptors.cpp
227

why do we need to exclude android?
SANITIZER_INTERCEPT_DLOPEN_DLCLOSE is ON there for other sanitizers

Enna1 added a comment.Apr 25 2023, 7:57 PM

I'm fine with waiting for HWASAN includes sanitizer_common_interceptors.inc :)

compiler-rt/lib/hwasan/hwasan_interceptors.cpp
227

In https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h#L438, I see SANITIZER_INTERCEPT_DLOPEN_DLCLOSE is ON for SI_LINUX_NOT_ANDROID. Am I miss something ?

I'm fine with waiting for HWASAN includes sanitizer_common_interceptors.inc :)

BTW There is D149234, so we don't need additional test

compiler-rt/lib/hwasan/hwasan_interceptors.cpp
227

Sorry, my mistake.

Enna1 updated this revision to Diff 517444.Apr 26 2023, 8:51 PM

remove additional test

We are going to use D150708 to incrementally add interceptors

Enna1 abandoned this revision.May 16 2023, 7:16 PM

We are going to use D150708 to incrementally add interceptors

Thanks for pointing this, I'll abandon this patch.