-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HWASAN]Implement memcmp interceptor in HWASAN #67204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer ChangesThe plan is to fix memcmp interceptor in HWASAN and remove the unsupported statement at that time. Full diff: https://github.com/llvm/llvm-project/pull/67204.diff 1 Files Affected:
diff --git a/compiler-rt/test/sanitizer_common/TestCases/memcmp.cpp b/compiler-rt/test/sanitizer_common/TestCases/memcmp.cpp
new file mode 100644
index 000000000000000..23fe8e2cfe0d620
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/memcmp.cpp
@@ -0,0 +1,15 @@
+// RUN: %clangxx -O0 %s -o %t && %run %t
+// XFAIL: *
+// UNSUPPORTED: lsan, ubsan
+// FIXME: HWASAN should work when we have intercepptors.
+// UNSUPPORTED: hwasan
+
+#include <cstring>
+#include <cstdio>
+
+int main(int argc, char** argv) {
+ int *x = new int(7);
+ delete x;
+ // Trigger use after free error.
+ return memcmp(x, &argc, sizeof(int)) == 0 ? 1 : 0;
+}
\ No newline at end of file
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
|
||
#include <string.h> | ||
int main(int argc, char **argv) { | ||
char a1[] = {static_cast<char>(argc), 2, 3, 4}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do heap allocation we can test in aliasing mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// XFAIL: *
I believe "// UNSUPPORTED: hwasan" does not work in hwasan, this is sanitizer_common feature.
I guess check-compiler-rt does not pass with this patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's worth porting bcmp_test.cpp and installing bcmp interceptor
memcmp_strict_test - maybe for consistencly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will implement the feature and include the test with in instead of disabling the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bcmp ?
b24c9b8
to
5175820
Compare
5175820
to
5aa8f3d
Compare
DON NOT SUBMIT - NEED TO TEST ON ARM
5aa8f3d
to
07c005c
Compare
|
||
#include <string.h> | ||
int main(int argc, char **argv) { | ||
char a1[] = {static_cast<char>(argc), 2, 3, 4}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bcmp ?
bcmp is OK for another PR |
8d6ca05
to
3cf5f0c
Compare
because the compiler knew it was 4 bytes so it just inlined the check. This looks like a bug in HWASAN code generation because there was no memory checks added to this code.
The plan is to fix memcmp interceptor in HWASAN and remove the unsupported statement at that time.