-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[msan] Intercept mallinfo2 #73729
Merged
vitalybuka
merged 4 commits into
main
from
users/vitalybuka/spr/msan-intercept-mallinfo2
Nov 29, 2023
Merged
[msan] Intercept mallinfo2 #73729
vitalybuka
merged 4 commits into
main
from
users/vitalybuka/spr/msan-intercept-mallinfo2
Nov 29, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4 [skip ci]
Created using spr 1.3.4
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesFull diff: https://github.com/llvm/llvm-project/pull/73729.diff 3 Files Affected:
diff --git a/compiler-rt/lib/msan/msan_interceptors.cpp b/compiler-rt/lib/msan/msan_interceptors.cpp
index dfecf6f7c470a6c..680b7d397ff0622 100644
--- a/compiler-rt/lib/msan/msan_interceptors.cpp
+++ b/compiler-rt/lib/msan/msan_interceptors.cpp
@@ -260,9 +260,18 @@ INTERCEPTOR(__sanitizer_struct_mallinfo, mallinfo) {
return sret;
}
+// Interceptor relies on NRVO and assumes that sret will be pre-allocated in
+// caller frame.
+INTERCEPTOR(__sanitizer_struct_mallinfo2, mallinfo2) {
+ __sanitizer_struct_mallinfo2 sret;
+ clear_mallinfo(&sret);
+ return sret;
+}
# define MSAN_MAYBE_INTERCEPT_MALLINFO INTERCEPT_FUNCTION(mallinfo)
+# define MSAN_MAYBE_INTERCEPT_MALLINFO2 INTERCEPT_FUNCTION(mallinfo2)
#else
#define MSAN_MAYBE_INTERCEPT_MALLINFO
+# define MSAN_MAYBE_INTERCEPT_MALLINFO2
#endif
#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
@@ -1787,6 +1796,7 @@ void InitializeInterceptors() {
MSAN_MAYBE_INTERCEPT_CFREE;
MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE;
MSAN_MAYBE_INTERCEPT_MALLINFO;
+ MSAN_MAYBE_INTERCEPT_MALLINFO2;
MSAN_MAYBE_INTERCEPT_MALLOPT;
MSAN_MAYBE_INTERCEPT_MALLOC_STATS;
INTERCEPT_FUNCTION(fread);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mallinfo.h b/compiler-rt/lib/sanitizer_common/sanitizer_mallinfo.h
index 4e58c02df835190..1c07e68e55a7d3b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mallinfo.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mallinfo.h
@@ -31,6 +31,10 @@ struct __sanitizer_struct_mallinfo {
int v[10];
};
+struct __sanitizer_struct_mallinfo2 {
+ uptr v[10];
+};
+
#endif
} // namespace __sanitizer
diff --git a/compiler-rt/test/msan/Linux/mallinfo.cpp b/compiler-rt/test/msan/Linux/mallinfo.cpp
index 3c3692969852f9b..f061218c615a3a9 100644
--- a/compiler-rt/test/msan/Linux/mallinfo.cpp
+++ b/compiler-rt/test/msan/Linux/mallinfo.cpp
@@ -8,5 +8,8 @@
int main(void) {
struct mallinfo mi = mallinfo();
assert(__msan_test_shadow(&mi, sizeof(mi)) == -1);
+
+ struct mallinfo2 mi2 = mallinfo2();
+ assert(__msan_test_shadow(&mi2, sizeof(mi2)) == -1);
return 0;
}
|
Created using spr 1.3.4
thurstond
approved these changes
Nov 29, 2023
vitalybuka
changed the base branch from
users/vitalybuka/spr/main.msan-intercept-mallinfo2
to
main
November 29, 2023 06:22
Hi, this commit broke the buildbot:
|
vitalybuka
added a commit
that referenced
this pull request
Nov 29, 2023
Should be fixed with 771e9cd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.