diff options
author | Kunqiu Chen <camsyn@foxmail.com> | 2025-06-19 16:25:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-19 16:25:51 +0800 |
commit | 681db064d221e9eef024ce0aef6165caa37fbfd2 (patch) | |
tree | 1ed84dab9e844cb3bb7f81f0edd9eeb6b20030b1 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 8f82c027c8969d965c43909da639e7790af19956 (diff) | |
download | llvm-681db064d221e9eef024ce0aef6165caa37fbfd2.zip llvm-681db064d221e9eef024ce0aef6165caa37fbfd2.tar.gz llvm-681db064d221e9eef024ce0aef6165caa37fbfd2.tar.bz2 |
[TSan] Make Shadow/Meta region inclusive-exclusive (#144647)
This commit changes the interval shadow/meta address check from
inclusive-inclusive ( $[\mathrm{start}, \mathrm{end}]$ ) to
inclusive-exclusive ( $[\mathrm{start}, \mathrm{end})$ ), to resolve the
ambiguity of the end point address. This also aligns the logic with the
check for `isAppMem` (i.e., inclusive-exclusive), ensuring consistent
behavior across all memory classifications.
1. The `isShadowMem` and `isMetaMem` checks previously used an
inclusive-inclusive interval, i.e., $[\mathrm{start}, \mathrm{end}]$,
which could lead to a boundary address being incorrectly classified as
both Shadow and Meta memory, e.g., 0x3000_0000_0000 in
`Mapping48AddressSpace`.
- What's more, even when Shadow doesn't border Meta, `ShadowMem::end`
cannot be considered a legal shadow address, as TSan protects the gap,
i.e., `ProtectRange(ShadowEnd(), MetaShadowBeg());`
2. `ShadowMem`/`MetaMem` addresses are derived from `AppMem` using an
affine-like transformation (`* factor + bias`). This transformation
includes two extra modifications: high- and low-order bits are masked
out, and for Shadow Memory, an optional XOR operation may be applied to
prevent conflicts with certain AppMem regions.
- Given that all AppMem regions are defined as inclusive-exclusive
intervals, $[\mathrm{start}, \mathrm{end})$, the resulting Shadow/Meta
regions should logically also be inclusive-exclusive.
Note: This change is purely for improving code consistency and should
have no functional impact. In practice, the exact endpoint addresses of
the Shadow/Meta regions are generally not reached.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions