Vitaly Buka
96928abb4d
[NFC][sanitizer] Pass user region into OnMapSecondary
2023-06-21 13:50:42 -07:00
Vitaly Buka
38dfcf96df
[NFC][sanitizer] Add OnMapSecondary callback
...
Now it implemented as OnMap everywhere, but in follow up patches
we can optimize Asan handler.
2023-06-21 13:33:41 -07:00
Jin Xin Ng
7639265af4
[sanitizer] Implement __sanitizer_get_allocated_size_fast
...
The primary motivation for this change is to allow FreeHooks to obtain
the allocated size of the pointer being freed in a fast, efficient manner.
Differential Revision: https://reviews.llvm.org/D151360
2023-05-26 00:19:47 +00:00
Fangrui Song
8c63dc6f6d
Internalize AllocationBegin functions after D147005
...
Reviewed By: thurston
Differential Revision: https://reviews.llvm.org/D148195
2023-04-13 10:28:58 -07:00
Thurston Dang
d644ab022a
Update __sanitizer_get_allocated_begin to return const void*
...
D147005 introduced __sanitizer_get_allocated_begin, with a return
value of void*. This involved a few naughty casts that dropped the
const. This patch adds back the const qualifier.
Differential Revision: https://reviews.llvm.org/D147489
2023-04-04 00:43:36 +00:00
Jie Fu
c81a322476
[compiler-rt] Fix -Wcast-qual after D147005 (NFC)
...
/home/jiefu/llvm-project/compiler-rt/lib/lsan/lsan_allocator.cpp:161:18: error: cast from 'const void *' to 'void *' drops const qualifier [-Werror,-Wcast-qual]
return (void *)beg;
^
1 error generated.
2023-04-04 07:40:34 +08:00
Thurston Dang
415b1cfd57
Add __sanitizer_get_allocated_begin API and implementations
...
This function will return the start of the allocation, if given a pointer that lies within an allocation. Otherwise, it returns NULL.
It will be useful for detecting dynamic TLS allocations in glibc >=2.25, which
uses malloc (see https://github.com/google/sanitizers/issues/1409#issuecomment-1214244142 ).
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D147005
2023-04-03 21:27:51 +00:00
Fangrui Song
de5416cb59
[dfsan] Support Linux AArch64
...
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake:ALL_DFSAN_SUPPORTED_ARCH
allows AArch64 but currently the instrumentation will crash.
Port Linux AArch64 memory mappings from msan but use
SizeClassAllocator64 for a slightly more efficient allocator (used by
asan/lsan). Change dfsan/lit.cfg.py to allow Linux aarch64. All tests
should pass.
* dfsan/origin_invalid.c uses x86_64 assembly. Just make it x86_64 specific.
* dfsan/interceptors.c our mallinfo interceptor takes an argument
instead of returning a struct. This does not work on AArch64 which
uses different registers for the two function types. Disable AArch64
as msan/Linux/mallinfo.cpp does.
Reviewed By: #sanitizers, vitalybuka
Differential Revision: https://reviews.llvm.org/D140770
2023-01-03 13:17:39 -08:00
Vitaly Buka
6318001209
[sanitizer] Support IsRssLimitExceeded in all sanitizers
...
Reviewed By: kstoimenov
Differential Revision: https://reviews.llvm.org/D115000
2021-12-03 12:45:44 -08:00
Andrew Browne
45f6d5522f
[DFSan] Change shadow and origin memory layouts to match MSan.
...
Previously on x86_64:
+--------------------+ 0x800000000000 (top of memory)
| application memory |
+--------------------+ 0x700000008000 (kAppAddr)
| |
| unused |
| |
+--------------------+ 0x300000000000 (kUnusedAddr)
| origin |
+--------------------+ 0x200000008000 (kOriginAddr)
| unused |
+--------------------+ 0x200000000000
| shadow memory |
+--------------------+ 0x100000008000 (kShadowAddr)
| unused |
+--------------------+ 0x000000010000
| reserved by kernel |
+--------------------+ 0x000000000000
MEM_TO_SHADOW(mem) = mem & ~0x600000000000
SHADOW_TO_ORIGIN(shadow) = kOriginAddr - kShadowAddr + shadow
Now for x86_64:
+--------------------+ 0x800000000000 (top of memory)
| application 3 |
+--------------------+ 0x700000000000
| invalid |
+--------------------+ 0x610000000000
| origin 1 |
+--------------------+ 0x600000000000
| application 2 |
+--------------------+ 0x510000000000
| shadow 1 |
+--------------------+ 0x500000000000
| invalid |
+--------------------+ 0x400000000000
| origin 3 |
+--------------------+ 0x300000000000
| shadow 3 |
+--------------------+ 0x200000000000
| origin 2 |
+--------------------+ 0x110000000000
| invalid |
+--------------------+ 0x100000000000
| shadow 2 |
+--------------------+ 0x010000000000
| application 1 |
+--------------------+ 0x000000000000
MEM_TO_SHADOW(mem) = mem ^ 0x500000000000
SHADOW_TO_ORIGIN(shadow) = shadow + 0x100000000000
Reviewed By: stephan.yichao.zhao, gbalats
Differential Revision: https://reviews.llvm.org/D104896
2021-06-25 17:00:38 -07:00
Jianzhou Zhao
1fb612d060
[dfsan] Add a DFSan allocator
...
This is a part of https://reviews.llvm.org/D101204
Reviewed By: morehouse
Differential Revision: https://reviews.llvm.org/D101666
2021-05-05 00:51:45 +00:00