[all-commits] [llvm/llvm-project] c4ac45: [test][asan] Simplify test
itrofimow via All-commits
all-commits at lists.llvm.org
Tue Apr 18 18:08:24 PDT 2023
Branch: refs/heads/release/16.x
Home: https://github.com/llvm/llvm-project
Commit: c4ac4533ea2b275f92dc440547e1aceb0a5c1866
https://github.com/llvm/llvm-project/commit/c4ac4533ea2b275f92dc440547e1aceb0a5c1866
Author: Vitaly Buka <vitalybuka at google.com>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
Log Message:
-----------
[test][asan] Simplify test
FileCheck is not very useful here.
(cherry picked from commit fd2cafbdc480920bcf4eb598788a906ec1f63c41)
Commit: ec006fb244fffadd84506885094974899dab06e7
https://github.com/llvm/llvm-project/commit/ec006fb244fffadd84506885094974899dab06e7
Author: Vitaly Buka <vitalybuka at google.com>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M compiler-rt/lib/asan/asan_linux.cpp
Log Message:
-----------
[nfc][asan] Reformat the file
(cherry picked from commit 3248ca0da01c73711896ddc86ae8b045b86726c8)
Commit: dbcd2e9330cd43921e13d8dce3d9b743ea2fe871
https://github.com/llvm/llvm-project/commit/dbcd2e9330cd43921e13d8dce3d9b743ea2fe871
Author: Ivan Trofimov <i.trofimow at yandex.ru>
Date: 2023-04-18 (Tue, 18 Apr 2023)
Changed paths:
M compiler-rt/lib/asan/asan_interceptors.cpp
M compiler-rt/lib/asan/asan_internal.h
M compiler-rt/lib/asan/asan_linux.cpp
M compiler-rt/test/asan/TestCases/Linux/swapcontext_test.cpp
Log Message:
-----------
[runtimes][asan] Fix swapcontext interception
Resetting oucp's stack to zero in swapcontext interception is incorrect,
since it breaks ucp cleanup after swapcontext returns in some cases:
Say we have two contexts, A and B, and we swapcontext from A to B, do
some work on Bs stack and then swapcontext back from B to A. At this
point shadow memory of Bs stack is in arbitrary state, but since we
can't know whether B will ever swapcontext-ed to again we clean up it's
shadow memory, because otherwise it remains poisoned and blows in
completely unrelated places when heap-allocated memory of Bs context
gets reused later (see https://github.com/llvm/llvm-project/issues/58633
for example). swapcontext prototype is swapcontext(ucontext* oucp,
ucontext* ucp), so in this example A is oucp and B is ucp, and i refer
to the process of cleaning up Bs shadow memory as ucp cleanup.
About how it breaks:
Take the same example with A and B: when we swapcontext back from B to A
the oucp parameter of swapcontext is actually B, and current trunk
resets its stack in a way that it becomes "uncleanupable" later. It
works fine if we do A->B->A, but if we do A->B->A->B->A no cleanup is
performed for Bs stack after B "returns" to A second time. That's
exactly what happens in the test i provided, and it's actually a pretty
common real world scenario.
Instead of resetting oucp's we make use of uc_stack.ss_flags to mark
context as "cleanup-able" by storing stack specific hash. It should be
safe since this field is not used in [get|make|swap]context functions
and is hopefully never meaningfully used in real-world scenarios (and i
haven't seen any).
Fixes https://github.com/llvm/llvm-project/issues/58633
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D137654
(cherry picked from commit b380e8b68951776656f286ecd079e2f30981905e)
Compare: https://github.com/llvm/llvm-project/compare/f2b0bf320824...dbcd2e9330cd
More information about the All-commits
mailing list