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

AddressSanitizer's FakeStack metadata can be rewrite by users #133640

Open
brandb97 opened this issue Mar 30, 2025 · 0 comments · May be fixed by #133689
Open

AddressSanitizer's FakeStack metadata can be rewrite by users #133640

brandb97 opened this issue Mar 30, 2025 · 0 comments · May be fixed by #133689
Labels
compiler-rt:asan Address sanitizer

Comments

@brandb97
Copy link

brandb97 commented Mar 30, 2025

AddressSanitizer save a &flag[pos] in the end of FakeStack, which can be rewrite by users. If you run this code snippet with -fsanitize=address, you would get SEGV signal. Because AddressSanitizer try to read &flag[pos] in __asan_stack_free, but it reads wrong place.

struct BigData {
        int x[1000];
};

void *test() {
        struct BigData x;
        int *y = x.x + 1032;
        for (int i = 0; i < 5000; i++)
                y[i] = 0xffffffff;
        return &x;
}

int main() {
        *(int *)test() = 1;
        return 0;
}

You should compile this program with clang -fsanitize=address source.c -o a.out. I'm using v18.1.6 to do this experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:asan Address sanitizer
Projects
None yet
3 participants