[BUG] libc++_shared.so is missing stack canary protection
Description
NDK version: 28.1.13356709 CMake version: 3.27+ React Native version: 0.78.0 Host OS: macOS ARM64 (Apple Silicon)
Steps to reproduce Build a standard React Native Android project with native dependencies with NDK. Extract the final app-release.apk with jadx. Check the status resources/lib/libc++_shared.so with checksec.
I am using a supported NDK
- [x] I have checked and the NDK I'm using is currently supported
Affected versions
r28
Hi Team, is this the same issue which i am also seeing after updating ndk version 28.2.13676358?
Hi Team, is this the same issue which i am also seeing after updating ndk version 28.2.13676358?
no. that's https://developer.android.com/guide/practices/page-sizes.
for this bug, just from objdump i can see that indeed there doesn't appear to be any use of stack protector in any of the libc++_shared.so binaries (i checked r28b).
the arm64 one is using pac/bti, though, so it would be "expected" there, given that they're mutually exclusive for the OS build.
these defaults should probably move out of the soong build system and into the compiler driver? (but with pac/bti not disabling stack-protector unless we know that the target definitely has it --- which probably means "that part would have to stay in soong".)
given that they're mutually exclusive for the OS build.
They are not incompatible though, correct? If they are not incompatible, we should add -fstack-protector=strong everywhere because not all system images enable pac/bti.
(cc: @yabinc )
If they are not incompatible, we should add -fstack-protector=strong everywhere because not all system images enable pac/bti.
Looks like we can add -fstack-protector=strong without interfering with pac/bti. Let's enable this for the NDK libc++ to start with.
@venk-ks would you be able to add this? We should also cherry-pick it to r574158/r30.
Will do!
I landed this fix (and the fix for #2185) before respinning the prebuilts for r574158, so this must be fixed for r30.