This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] intercept memset_pattern macOs api
Needs ReviewPublic

Authored by devnexen on Sep 17 2022, 5:22 AM.

Diff Detail

Event Timeline

devnexen created this revision.Sep 17 2022, 5:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2022, 5:22 AM
Herald added a subscriber: Enna1. · View Herald Transcript
devnexen requested review of this revision.Sep 17 2022, 5:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2022, 5:22 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
devnexen updated this revision to Diff 460995.Sep 17 2022, 5:34 AM
wrotki added a comment.Oct 6 2022, 6:55 PM

I wonder why the implementation is different from memset interceptor, looking at sanitizer_common_interceptors(868):

#if SANITIZER_INTERCEPT_MEMSET
INTERCEPTOR(void *, memset, void *dst, int v, uptr size) {

void *ctx;
COMMON_INTERCEPTOR_MEMSET_IMPL(ctx, dst, v, size);

}

#define INIT_MEMSET COMMON_INTERCEPT_FUNCTION(memset)
#else
#define INIT_MEMSET

#endif

Common sense tells me that memset and memset_patternx should be handled in roughly the same way (the difference being one byte versus multibyte pattern). Also, perhaps the code for them should be colocated, i.e. code starting with '#if SANITIZER_INTERCEPT_MEMSET_PATTERN' should perhaps immediately follow the '#if SANITIZER_INTERCEPT_MEMSET' sequence.

devnexen updated this revision to Diff 466384.Oct 9 2022, 12:58 PM

I am actually not very familiar with the memset_pattern API - is it available on every OS? What about various OS versions, when was is introduced? I see above that the diff build failed on Debian (not sure if that's reliable, but it's a hint).

yln added a comment.EditedOct 14 2022, 10:58 AM

Can you give an explanation of the scenario (false positive, false negative?) which this patch fixes. Please put this information also in the commit message.

Was this scenario LLVM rewriting/specializing a vanilla memset_pattern() call to memset_patternXX() for optimization? Can we add such an "integration style" test? Maybe we can assert in a LIT RUN: nm <binary> | grep memset_pattern4 ... line that it was rewritten.

Thanks! :)