Before this patch when running HWASAN on x86_64 with memory tagging support we got a bunch of false memory leak reports. The reason for that is that the heuristic used to detect if an 8 bytes could be a user pointer was not valid when memory tagging is used as the top byte could contain non-zero information.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
276 | we should query this from kernel, like in CanUseTaggingAbi |
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
275–277 | I am confused. | |
276 | Maybe it's fine keep it simple and handle the worst case https://lwn.net/Articles/902094/ |
compiler-rt/lib/lsan/lsan_common.cpp | ||
---|---|---|
275–277 | Never mind, the point to distinguish user space, so we check top bits AFTER top byte. | |
276 | I measured "return true" and on average it's 1.5% regressions. So it's measureable, current 17 bit vs 8 bit, I can't measure a difference, but still think it's safe to keep as much as possible bits, 11 should work for us. Please drop TODO that we will need to refactore this code for LAM48, or 5 level page tables. |
compiler-rt/test/lsan/TestCases/user_pointer.cpp | ||
---|---|---|
9–17 ↗ | (On Diff #541254) | This code actually generates memory leaks because the allocated memory is not referenced by any pointer. I had a version where there are 2 arrays: one with the pointer and the other one with & ' p & (255ULL << 48)', but I am not sure how with would help. Probably the best is just to leave with one |
compiler-rt/test/lsan/TestCases/user_pointer.cpp | ||
---|---|---|
14 ↗ | (On Diff #541283) | I see. So if we set masked bits, it will still fail other LSAN checks so the test as is is not very useful, but not easy way change that. |
compiler-rt/test/lsan/TestCases/user_pointer.cpp | ||
---|---|---|
14 ↗ | (On Diff #541283) | I will catch false positives. This test failed with HWASAN on x86 without my fix. Granted a bunch of other tests would have also failed, but it is good to have an explicit one. |
I am confused.
This one masking out 55:48, not the top byte?