Skip to content
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

[compiler-rt] madvise interception #76562

Closed
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 29, 2023

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: David CARLIER (devnexen)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/76562.diff

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc (+10-1)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index ba46707516971f..bfd72c5897e45e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -7498,10 +7498,19 @@ INTERCEPTOR(int, mprotect, void *addr, SIZE_T sz, int prot) {
   MprotectMallocZones(addr, prot);
   return REAL(mprotect)(addr, sz, prot);
 }
+
+INTERCEPTOR(int, madvise, uptr addr, SIZE_T sz, int advice) {
+  void *ctx;
+  if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+    return (int)internal_madvise(addr, sz, advice);
+  COMMON_INTERCEPTOR_ENTER(ctx, madvise, addr, sz, advice);
+  return REAL(madvise)(addr, sz, advice);
+}
 #define INIT_MMAP                                                              \
   COMMON_INTERCEPT_FUNCTION(mmap);                                             \
   COMMON_INTERCEPT_FUNCTION(munmap);                                           \
-  COMMON_INTERCEPT_FUNCTION(mprotect);
+  COMMON_INTERCEPT_FUNCTION(mprotect);                                         \
+  COMMON_INTERCEPT_FUNCTION(madvise);
 #else
 #define INIT_MMAP
 #endif

Copy link

github-actions bot commented Dec 29, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

COMMON_INTERCEPT_FUNCTION(munmap); \
COMMON_INTERCEPT_FUNCTION(mprotect);

INTERCEPTOR(int, madvise, uptr addr, SIZE_T sz, int advice) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need it if it does nothing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true..

@devnexen devnexen closed this Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants