Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support x86-64 5-level paging for ASan (and possibly other sanitizers) #1745

Open
thurstond opened this issue Apr 16, 2024 · 0 comments
Open

Comments

@thurstond
Copy link
Contributor

thurstond commented Apr 16, 2024

The failure mode for ASan is explained by the test added in llvm/llvm-project@6f66b12:

    [sanitizer-common] Expand testing for 56-bit address spaces
    
    This patch adds mmap_56bit_test.c, which attempts to deliberately
    mmap above 2^47. This currently exposes a failure on ASan on
    systems with 56-bit user address spaces, because it allows an mmap
    above 2^47 but the shadow mapping is only set up for a 2^47 user address
    space.
    ...
    Differential Revision: https://reviews.llvm.org/D149176

Why it fails

ASan's dynamic shadow algorithm automatically figures out the address space size:

// compiler-rt/lib/asan/asan_rtl.cpp
static void InitializeHighMemEnd() {
#if !ASAN_FIXED_MAPPING
  kHighMemEnd = GetMaxUserVirtualAddress();

edit:
but the MaxVirtualAddress is hardcoded in compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Suggested fixes for ASan

  • (better) correctly figure out the max user virtual address (such as by deliberately trying to map above 47-bit). The dynamic shadow algorithm will then fix itself, and ASan should work with the full address space.
  • (worse) change the mmap interceptor to prevent it from mapping above 47-bit (i.e., pretend it is a 47-bit system).

Other sanitizers

Similar issues apply to most other sanitizers; those are harder to fix, because they mostly use handcrafted mappings rather than dynamic shadows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant