ndk icon indicating copy to clipboard operation
ndk copied to clipboard

[BUG] libc++_shared.so is missing stack canary protection

Open PyaeSoneHtet opened this issue 1 year ago • 7 comments

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.

Image

I am using a supported NDK

  • [x] I have checked and the NDK I'm using is currently supported

Affected versions

r28

PyaeSoneHtet avatar Jun 18 '25 05:06 PyaeSoneHtet

Hi Team, is this the same issue which i am also seeing after updating ndk version 28.2.13676358?

Image

parmesh-mahore avatar Jul 28 '25 11:07 parmesh-mahore

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.

enh-google avatar Jul 28 '25 12:07 enh-google

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".)

enh-google avatar Jul 28 '25 12:07 enh-google

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 )

pirama-arumuga-nainar avatar Oct 02 '25 23:10 pirama-arumuga-nainar

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.

pirama-arumuga-nainar avatar Oct 03 '25 00:10 pirama-arumuga-nainar

Will do!

venk-ks avatar Oct 03 '25 17:10 venk-ks

I landed this fix (and the fix for #2185) before respinning the prebuilts for r574158, so this must be fixed for r30.

venk-ks avatar Nov 20 '25 23:11 venk-ks