Forums - Android 10, ADSP, and .so permissions failures

4 posts / 0 new
Last post
Android 10, ADSP, and .so permissions failures
robert.lacroix
Join Date: 9 Apr 20
Posts: 2
Posted: Thu, 2021-01-21 12:15

Using NP SDK 1.36, Android Studio 3.6 in August 2020, I was able to build and execute machine learning code using NDK with a custom-written JNI, by setting ADSP_LIBRARY_PATH exactly as per the instructions at https://developer.qualcomm.com/docs/snpe/dsp_runtime.html (section "For Android APKs").

Using NP SDK 1.36, Android Studio 4.0 today, testing on a Samsung A70 and a Samsung S8, it seems that the DSP .so libs expect to be able to spawn command shells and such, and it fails. My hypothesis is that as per https://developer.android.com/about/versions/10/behavior-changes-10, untrusted apps can no longer execute code out of the native library dir (that is only my best guess at this point).

In my JNI layer, I can execute zdl::SNPE::SNPEFactory::getLibraryVersion() no problem, which means libSNPE.so is loaded and aceessible. However, even after setting ADSP_LIBRARY_PATH as per the Qualcomm recommended method, the call to zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::DSPcreates a litany of logcat spew in my unit tests (and returns false) (see below)

I do not use the snpe-release.aar package because our application is native code, we expose our native APIs to Java via JNI.

Is there a way to have our native libXYZ.so depend on libSNPE.so and all the SNPE DSP libs, while using snpe-release.aar and platform-validator.aar to deliver the SNPE so files, or is that a recipe for disaster?

Any concrete guidance welcome.

Logcat when running on Samsung A70 with Android 10 (Snapdragon 675):

22 02:44:26.019  9122  9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: In doThisBefore...
01-22 02:44:26.022  9122  9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: Files found in nativeLibraryDir:
01-22 02:44:26.022  9122  9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: Files size: 13
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_domains.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_domains_skel.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_skel.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libwrAPI.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_domains_system.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libc++_shared.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libwrnchJni.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_domains_v2.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_v65_domains_v2_skel.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_v66_domains_v2_skel.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_adsp.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libSNPE.so
01-22 02:44:26.022  9122  9251 D Files   : FileName:libsnpe_dsp_domains_v2_system.so
01-22 02:44:26.064  9122  9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: SNPE Library version is 1.36.0.746
01-22 02:44:26.066  9122  9251 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file fastrpc_shell_3. (Permission denied)
01-22 02:44:26.066  9122  9251 E ai.wrnch.api.test: Error 0xd: open_shell failed for domain 3
01-22 02:44:26.095  9122  9251 I ai.wrnch.api.test: Successfully created user PD on domain 3 (attrs 0x1, debug_trace 0x1)
01-22 02:44:26.095  9122  9251 I ai.wrnch.api.test: fastrpc_perf_init: enabled RPC traces (kernel 0, dsp 0) with frequency 1000
01-22 02:44:26.106  9122  9336 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file testsig-0xa4e23076.so. (Permission denied)
01-22 02:44:26.107  9122  9336 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file testsig.so. (Permission denied)
01-22 02:44:26.112  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.112  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.112  9122  9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.112  9122  9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.112  9122  9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
01-22 02:44:26.118  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.118  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.118  9122  9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.118  9122  9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.118  9122  9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
01-22 02:44:26.123  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.123  9122  9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.123  9122  9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.123  9122  9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.123  9122  9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
 

 

 

  • Up0
  • Down0
gal.safra1
Join Date: 5 Sep 22
Posts: 6
Posted: Mon, 2023-04-17 23:50

any update about this one?

  • Up0
  • Down0
weihuan
Join Date: 12 Apr 20
Posts: 270
Posted: Fri, 2023-04-21 06:33

Dear developer,

You might need to add permission of libcdsprpc.so to your Mainifest.xml to recoginze by SELinux.

 

BR.

Wei

  • Up0
  • Down0
gal.safra1
Join Date: 5 Sep 22
Posts: 6
Posted: Mon, 2023-04-24 01:06

Thank you for your reply. 
Can you further explain your answer?

i linked to  libcdsprpc.so from native cmake, but still getting
 

vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:2058: Error: Device node open failed for domain 3 (errno Permission denied)
vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:1329: Error 0x3b: remote_get_info failed to get dsp attribute 1 for domain 3
vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:1481: Error 0x3b: remote_handle_control_domain failed for request ID 2 on domain 3
vendor/qcom/proprietary/commonsys-intf/adsprpc/src/fastrpc_apps_user.c:1492: Error 0x3b: remote_handle_control failed for request ID 2
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.