diff --git a/compiler-rt/lib/dfsan/dfsan_interceptors.cpp b/compiler-rt/lib/dfsan/dfsan_interceptors.cpp --- a/compiler-rt/lib/dfsan/dfsan_interceptors.cpp +++ b/compiler-rt/lib/dfsan/dfsan_interceptors.cpp @@ -46,12 +46,24 @@ return res; } +INTERCEPTOR(int, munmap, void *addr, SIZE_T length) { + int res = REAL(munmap)(addr, length); + if (res != -1) { + uptr beg_shadow_addr = (uptr)__dfsan::shadow_for(addr); + void *end_addr = (void *)((uptr)addr + RoundUpTo(length, GetPageSize())); + uptr end_shadow_addr = (uptr)__dfsan::shadow_for(end_addr); + ReleaseMemoryPagesToOS(beg_shadow_addr, end_shadow_addr); + } + return res; +} + namespace __dfsan { void InitializeInterceptors() { CHECK(!interceptors_initialized); INTERCEPT_FUNCTION(mmap); INTERCEPT_FUNCTION(mmap64); + INTERCEPT_FUNCTION(munmap); interceptors_initialized = true; }