Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/hwasan/hwasan_interceptors.cpp | ||
---|---|---|
216 | HWASan's mmap interceptor does not tag memory or allow MAP_FIXED with a tagged address, so there should be no need to zero-tag memory in the munmap interceptor. (To the extent that zero-tagging fixes anything, it means there is a bug elsewhere.) |
compiler-rt/test/hwasan/TestCases/munmap.c | ||
---|---|---|
26 | What is the purpose of testing that this works? Tagging the pointer and memory for an mmap'ed allocation is not something that should happen in practice. |
compiler-rt/test/hwasan/TestCases/munmap.c | ||
---|---|---|
26 | Here is my understanding of what is going on. Feel free to double-check with vitalybuka@. While we investigated a bug we figured out that the area for the stack is mmaped. After that HWASAN tags that memory during execution from instrumented code to detect UAR. What happens after that the process uses vfork to spawn a child process where we get the tag mismatch error. The reason is that the memory is unmmaped in the child process without being untagged and then the next mmap request returns the same memory with tagged shadow memory. |
compiler-rt/test/hwasan/TestCases/munmap.c | ||
---|---|---|
26 | Wouldn't it be better to zero-tag the memory in the mmap interceptor, rather than the munmap interceptor? It would mean that un-mmap'ed pages would continue to be protected against illegal accesses, until such time that the memory is actually reused by mmap. |
we need the same for Asan, in a separate patch
compiler-rt/lib/hwasan/hwasan_interceptors.cpp | ||
---|---|---|
208 | Let's do __hwasan::TagMemoryAligned(reinterpret_cast<uptr>(addr), length, 0); here as well | |
compiler-rt/test/hwasan/TestCases/munmap.c | ||
26 | pages are already protected as they are not mapped, so you'll get segv I guess it will not hurt to zero tag in mmap as well. | |
30 | as this is hwasan test, you can use __hwasan_test_shadow, it's going to be simple: __hwasan_tag_memory mmap(fixed) __hwasan_test_shadow __hwasan_tag_memory munmap __hwasan_test_shadow |
compiler-rt/test/hwasan/TestCases/munmap.c | ||
---|---|---|
30 | Also added some extra checks. PTAL. |
Let's do __hwasan::TagMemoryAligned(reinterpret_cast<uptr>(addr), length, 0); here as well