@@ -47,6 +47,7 @@ void OSSpinLockLock(volatile OSSpinLock *__lock);
47
47
#include < stdarg.h>
48
48
#include < stdio.h>
49
49
#if SANITIZER_LINUX
50
+ #include < linux/mman.h>
50
51
#include < sys/inotify.h>
51
52
#endif
52
53
#include < sys/select.h>
@@ -870,6 +871,32 @@ INTERCEPTOR(void *, mmap64, void *addr, size_t length, int prot, int flags,
870
871
#define RTSAN_MAYBE_INTERCEPT_MMAP64
871
872
#endif // SANITIZER_INTERCEPT_MMAP64
872
873
874
+ #if SANITIZER_LINUX
875
+ // Note that even if rtsan is ported to netbsd, it has a slighty different
876
+ // and non-variadic signature
877
+ INTERCEPTOR (void *, mremap, void *oaddr, size_t olength, size_t nlength,
878
+ int flags, ...) {
879
+ __rtsan_notify_intercepted_call (" mremap" );
880
+
881
+ // the last optional argument is only used in this case
882
+ // as the new page region will be assigned to. Is ignored otherwise.
883
+ if (flags & MREMAP_FIXED) {
884
+ va_list args;
885
+
886
+ va_start (args, flags);
887
+ void *naddr = va_arg (args, void *);
888
+ va_end (args);
889
+
890
+ return REAL (mremap)(oaddr, olength, nlength, flags, naddr);
891
+ }
892
+
893
+ return REAL (mremap)(oaddr, olength, nlength, flags);
894
+ }
895
+ #define RTSAN_MAYBE_INTERCEPT_MREMAP INTERCEPT_FUNCTION (mremap)
896
+ #else
897
+ #define RTSAN_MAYBE_INTERCEPT_MREMAP
898
+ #endif
899
+
873
900
INTERCEPTOR (int , munmap, void *addr, size_t length) {
874
901
__rtsan_notify_intercepted_call (" munmap" );
875
902
return REAL (munmap)(addr, length);
@@ -1346,6 +1373,7 @@ void __rtsan::InitializeInterceptors() {
1346
1373
INTERCEPT_FUNCTION (posix_memalign);
1347
1374
INTERCEPT_FUNCTION (mmap);
1348
1375
RTSAN_MAYBE_INTERCEPT_MMAP64;
1376
+ RTSAN_MAYBE_INTERCEPT_MREMAP;
1349
1377
INTERCEPT_FUNCTION (munmap);
1350
1378
RTSAN_MAYBE_INTERCEPT_MADVISE;
1351
1379
RTSAN_MAYBE_INTERCEPT_POSIX_MADVISE;
0 commit comments