Unable to load a shared TA library with error Segmentation fault (Signal SIGSEGV) after added libraries OpenCV and relic
Closed this issue · 7 comments
Hello Open-TEE devs,
I asked the same question by sent an email to the mailing list. The email was unable to be delivered. Trying to yield on the freenode, but seems no one respond. So I back to here again.
I am working on a research project in the university of Auckland. We are using the Open-TEE framework.
Currently, I am trying to use the open-cv and an encryption library called relic in the trusted environment. But when the system to load the shared library, it reports a segmentation fault error. If I excluded the opencv and relic libraries, the TA library can be loaded successfully.
The way I include the library is in the sfc.qbs file.
For the set libraries:
- For shared libraries, The *.so path are added into /etc/ld.so.conf.d/ and sudo ldconfig is executed.
- For static library, relic, the -fPIC option is added when compiling.
I added library settings into the TA's qbs config file:
cpp.cxxLanguageVersion:"c++11"
cpp.warningLevel:"none" // both of those libraries have some warnings
cpp.includePaths: ["../include" , "/path_of_relic/include" , "/usr/local/include/opencv" ]
cpp.libraryPaths: ["path_relic" , "path_opencv" ]
cpp.staticLibraries: ["relic_pic" , "opencv_core" , "opencv_imgcodecs" , "opencv_highgui" , "opencv_imgproc" ]
I also tried to include the shared opencv shared libraries:
cpp.dynamicLibraries: ['opencv_core' , 'opencv_imgcodecs' , 'opencv_highgui' , 'opencv_imgproc' ]
but I had same problem - the TA library libta_scf.so got rejected.
I checked the syslog, the log is:
/home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:201 libta_scf.so : properties section is not found Jul 19 15:55:09 Lulu tee_manager: /home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:227 TA "libta_scf.so" rejected~~~ Jul 20 12:05:08 Lulu kernel: [ 7125.177214] libta_scf.so[808]: segfault at 31a ip 00007f2b54935d43 sp 00000000018a99a0 error 4 in ld-2.23.so[7f2b5492c000+26000]
The debugger log provides more info (see the bold italic text), but I still unable to figure out the cause of the TA library got rejected.
--- token barrier ---
dNOTE: INFERIOR RUN REQUESTED
sRun requested...
dState changed from InferiorStopOk(14) to InferiorRunRequested(10) [master]
sStep next requested...
1087-exec-next
1087^running
dNOTE: INFERIOR RUN OK
sRunning.
dState changed from InferiorRunRequested(10) to InferiorRunOk(11) [master]
*running,thread-id="all"
dNOTE: INFERIOR STILL RUNNING IN STATE InferiorRunOk.*_~"\nThread "
~"2.1 "libta_scf.so" received signal SIGSEGV, Segmentation fault.\n"
~"do_lookup_x (undef_name=undef_name@entry=0x7f7bceaa18f8 "_ITM_deregisterTMCloneTable", new_hash=new_hash@entry=2247416213, old_hash=old_hash@entry=0x706b80, ref=0x7f7bceaa1390, result=result@entry=0x706b90, scope=, i=0, version=0x0, flags=1, skip=0x0, type_class=4, undef_map=0x7188d0) at dl-lookup.c:377\n"
&"377\tdl-lookup.c: No such file or directory.\n"
stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation fault",frame={addr="0x00007f7bd9d7bd43",func="do_lookup_x",args=[{name="undef_name",value="0x7f7bceaa18f8 "_ITM_deregisterTMCloneTable""},{name="undef_name@entry",value="0x7f7bceaa18f8 "ITM_deregisterTMCloneTable""},{name="new_hash",value="2247416213"},{name="new_hash@entry",value="2247416213"},{name="old_hash",value="0x706b80"},{name="old_hash@entry",value="0x706b80"},{name="ref",value="0x7f7bceaa1390"},{name="result",value="0x706b90"},{name="result@entry",value="0x706b90"},{name="scope",value=""},{name="i",value="0"},{name="version",value="0x0"},{name="flags",value="1"},{name="skip",value="0x0"},{name="type_class",value="4"},{name="undef_map",value="0x7188d0"}],file="dl-lookup.c",fullname="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377"},thread-id="2",stopped-threads="all",core="2"
dNOTE: INFERIOR SPONTANEOUS STOP
sStopped.
dState changed from InferiorRunOk(11) to InferiorStopOk(14) [master]
dHANDLING SIGNAL SIGSEGV
sStopped: Segmentation fault (Signal SIGSEGV).1088-thread-info
1088^done,threads=[{id="2",target-id="Thread 0x7f7bd9f74700 (LWP 17461)",name="libta_scf.so",frame={level="0",addr="0x00007f7bd9d7bd43",func="do_lookup_x",args=[{name="undef_name",value="0x7f7bceaa18f8 "_ITM_deregisterTMCloneTable""},{name="undef_name@entry",value="0x7f7bceaa18f8 "_ITM_deregisterTMCloneTable""},{name="new_hash",value="2247416213"},{name="new_hash@entry",value="2247416213"},{name="old_hash",value="0x706b80"},{name="old_hash@entry",value="0x706b80"},{name="ref",value="0x7f7bceaa1390"},{name="result",value="0x706b90"},{name="result@entry",value="0x706b90"},{name="scope",value=""},{name="i",value="0"},{name="version",value="0x0"},{name="flags",value="1"},{name="skip",value="0x0"},{name="type_class",value="4"},{name="undef_map",value="0x7188d0"}],file="dl-lookup.c",fullname="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377"},state="stopped",core="2"}],current-thread-id="2"
-1089threadnames 20
-1090python theDumper.fetchStack({"limit":20,"nativemixed":0,"token":1090})&"threadnames 20\n"
~"[]\n"
1089^done&"python theDumper.fetchStack({"limit":20,"nativemixed":0,"token":1090})\n"
~"frames=[frame={level="0",address="0x7f7bd9d7bd43",function="do_lookup_x",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="1",address="0x7f7bd9d7c94f",function="_dl_lookup_symbol_x",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="829",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="2",address="0x7f7bd9d7e5ad",function="elf_machine_rela",file="/build/glibc-GKVZIf/glibc-2.23/elf/../sysdeps/x86_64/dl-machine.h",line="301",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="3",address="0x7f7bd9d7e5ad",function="elf_dynamic_do_Rela",file="/build/glibc-GKVZIf/glibc-2.23/elf/do-rel.h",line="137",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="4",address="0x7f7bd9d7e5ad",function="_dl_relocate_object",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-reloc.c",line="258",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="5",address="0x7f7bd9d87681",function="dl_open_worker",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-open.c",line="435",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="6",address="0x7f7bd9d82394",function="_dl_catch_error",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-error.c",line="187",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="7",address="0x7f7bd9d86bd9",function="_dl_open",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-open.c",line="660",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="8",address="0x7f7bd9b6ef09",function="dlopen_doit",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlopen.c",line="66",module="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",language="c"},frame={level="9",address="0x7f7bd9d82394",function="_dl_catch_error",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-error.c",line="187",module="/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.23.so",language="c"},frame={level="10",address="0x7f7bd9b6f571",function="_dlerror_run",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlerror.c",line="163",module="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",language="c"},frame={level="11",address="0x7f7bd9b6efa1",function="__dlopen",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlopen.c",line="87",module="/usr/lib/debug/lib/x86_64-linux-gnu/libdl-2.23.so",language="c"},frame={level="12",address="0x7f7bd937f174",function="load_ta",file="/home/r0ng/tools/OpenTEE/emulator/launcher/dynamic_loader.c",line="53",module="/home/r0ng/tools/OpenTEE/debug/libLauncherApi.so",language="c"},frame={level="13",address="0x7f7bd9383c47",function="ta_process_loop",file="/home/r0ng/tools/OpenTEE/emulator/launcher/ta_process.c",line="161",module="/home/r0ng/tools/OpenTEE/debug/libLauncherApi.so",language="c"},frame={level="14",address="0x7f7bd968eb5d",function="clone",file="/build/glibc-GKVZIf/glibc-2.23/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S",line="109",module="/usr/lib/debug/lib/x86_64-linux-gnu/libc-2.23.so",language="c"}]\n"
1090^done
1091-stack-select-frame 12
1092python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["inspect","local","return","watch"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":1092,"typeformats":{},"watchers":[{"exp":"70617273655f746565635f726573756c7428726573756c7429","iname":"watch.0"},{"exp":"2a73657373696f6e436f6e74657874","iname":"watch.1"},{"exp":"28636861722a2970617468","iname":"watch.2"}]})1091^done
&"python theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["inspect","local","return","watch"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":1092,"typeformats":{},"watchers":[{"exp":"70617273655f746565635f726573756c7428726573756c7429","iname":"watch.0"},{"exp":"2a73657373696f6e436f6e74657874","iname":"watch.1"},{"exp":"28636861722a2970617468","iname":"watch.2"}]})\n"
~"data=[{iname="local.path",name="path",origaddr="0x707398",numchild="0",type="char *",valueencoded="utf8",value="2F686F6D652F72306E672F746F6F6C732F4F70656E5445452F64656275672F5441732F6C696274615F7363662E736F",address="0x7075b0",},{iname="local.callbacks",name="callbacks",origaddr="0x707390",numchild="0",origaddr="0x707390",type="ta_interface *",value="0x0",address="0x7f7bd95873a0",},{iname="local.tmp_cb",name="tmp_cb",numchild="7",type="ta_interface",value="",address="0x7073f0",},{iname="local.err",name="err",numchild="0",type="char *",value="0x0",address="0x7073a8",},{iname="local.internal_api_calls",name="internal_api_calls",numchild="7",type="internal_api_callbacks",value="",address="0x7073b0",},{iname="local.func",name="func",numchild="8",type="char [8]",valueencoded="utf8",value="6C6F61645F746100",address="0x7f7bd93843f8",},{iname="watch.0",wname="70617273655F746565635F726573756C7428726573756C7429",numchild="0",type=" ",value="",},{iname="watch.1",wname="2A73657373696F6E436F6E74657874",numchild="0",type=" ",value="",},{iname="watch.2",wname="28636861722A2970617468",origaddr="0x707398",numchild="0",type="char *",valueencoded="utf8",value="2F686F6D652F72306E672F746F6F6C732F4F70656E5445452F64656275672F5441732F6C696274615F7363662E736F",address="0x7075b0",},],typeinfo=[],partial="0"\n"
1092^done
Rebuild Watchmodel 55 @ 16:29:39.914 [20601ms]
sFinished retrieving data
Could anyone enlight me and let me what am I missed?
Thanks in advance
r0nG
Hi r0nG,
I am guessing that you are not writing the TA property section to TA
binary. Make sure you are doing one of these at our TA:
-For examle make something like open_tee_conf.c file and include that into
compiling: https://github.com/Open-TEE/TAs/tree/master/example_ta
-Or use SET_TA_PROPERTIES -macro directly at our TA source files:
https://github.com/Open-TEE/TAs/blob/master/example_digest_ta/example_digest_ta.c
Please let me know if this helps. If not then we can debug some more :)
-Tanel
2016-07-19 6:27 GMT+01:00 r0nG notifications@github.com:
Hello devs,
I asked the same question by sent an email to the mailing list. The email
was unable to be delivered. Trying to yield on the freenode, but seems no
one respond. So I back to here again.I am working on a research project in the university of Auckland. We are
using the Open-TEE framework.Currently, I am trying to use the open-cv and an encryption library called
relic in the trusted environment. But when the system to load the shared
library, it reports a segmentation fault error. If I excluded the opencvand relic libraries, the TA library can be loaded successfully.
The way I include the library is in the sfc.qbs file, I added library
settings:cpp.cxxLanguageVersion:"c++11"
cpp.warningLevel:"none" // both of those libraries have some warnings
cpp.includePaths: ["../include"
, "/path_of_relic/include"
, "/usr/local/include/opencv"
]
cpp.libraryPaths: ["path_relic"
, "path_opencv"
]
cpp.staticLibraries: ["relic_pic"
, "opencv_core"
, "opencv_imgcodecs"
, "opencv_highgui"
, "opencv_imgproc"
]I also tried to include the shared opencv shared libraries:
cpp.dynamicLibraries: ['opencv_core'
, 'opencv_imgcodecs'
, 'opencv_highgui'
, 'opencv_imgproc'
]but I had same problem - the TA library libta_scf.so got rejected.
I checked the syslog, the log is:
Jul 19 15:55:09 Lulu tee_manager:
/home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:201
libta_scf.so : properties section is not found
Jul 19 15:55:09 Lulu tee_manager:
/home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:227 TA
"libta_scf.so" rejected
The debugger log provides more info (see the bold italic text), but I
still unable to figure out the cause of the TA library got rejected.--- token barrier ---
dNOTE: INFERIOR RUN REQUESTED
sRun requested...
dState changed from InferiorStopOk(14) to InferiorRunRequested(10) [master]
sStep next requested...
1087-exec-next
1087^running
dNOTE: INFERIOR RUN OK
sRunning.
dState changed from InferiorRunRequested(10) to InferiorRunOk(11) [master]
*running,thread-id="all"
dNOTE: INFERIOR STILL RUNNING IN STATE InferiorRunOk._~"\nThread " ~"2.1 "libta_scf.so" received signal SIGSEGV, Segmentation
fault.\n" ~"do_lookup_x (undef_name=undef_name@entry=0x7f7bceaa18f8
"_ITM_deregisterTMCloneTable", new_hash=new_hash@entry=2247416213
<2247416213>, old_hash=old_hash@entry=0x706b80, ref=0x7f7bceaa1390,
result=result@entry=0x706b90, scope=, i=0, version=0x0, flags=1, skip=0x0,
type_class=4, undef_map=0x7188d0) at dl-lookup.c:377\n" &"377\tdl-lookup.c:
No such file or directory.\n"
*stopped,reason="signal-received",signal-name="SIGSEGV",signal-meaning="Segmentation
fault",frame={addr="0x00007f7bd9d7bd43",func="do_lookup_x",args=[{name="undef_name",value="0x7f7bceaa18f8
"_ITM_deregisterTMCloneTable""},{name="undef_name@entry",value="0x7f7bceaa18f8
"ITM_deregisterTMCloneTable""},{name="new_hash",value="2247416213
<2247416213>"},{name="new_hash@entry",value="2247416213
<2247416213>"},{name="old_hash",value="0x706b80"},{name="old_hash@entry",value="0x706b80"},{name="ref",value="0x7f7bceaa1390"},{name="result",value="0x706b90"},{name="result@entry",value="0x706b90"},{name="scope",value=""},{name="i",value="0"},{name="version",value="0x0"},{name="flags",value="1"},{name="skip",value="0x0"},{name="type_class",value="4"},{name="undef_map",value="0x7188d0"}],file="dl-lookup.c",fullname="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377"},thread-id="2",stopped-threads="all",core="2"
dNOTE: INFERIOR SPONTANEOUS STOP sStopped. dState changed from
InferiorRunOk(11) to InferiorStopOk(14) [master] dHANDLING SIGNAL SIGSEGV
sStopped: Segmentation fault (Signal SIGSEGV).1088-thread-info
1088^done,threads=[{id="2",target-id="Thread 0x7f7bd9f74700 (LWP
17461)",name="libta_scf.so",frame={level="0",addr="0x00007f7bd9d7bd43",func="do_lookup_x",args=[{name="undef_name",value="0x7f7bceaa18f8
"_ITM_deregisterTMCloneTable""},{name="undef_name@entry",value="0x7f7bceaa18f8
"_ITM_deregisterTMCloneTable""},{name="new_hash",value="2247416213
"},{name="new_hash@entry",value="2247416213
"},{name="old_hash",value="0x706b80"},{name="old_hash@entry
",value="0x706b80"},{name="ref",value="0x7f7bceaa1390"},{name="result",value="0x706b90"},{name="result@entry
",value="0x706b90"},{name="scope",value=""},{name="i",value="0"},{name="version",value="0x0"},{name="flags",value="1"},{name="skip",value="0x0"},{name="type_class",value="4"},{name="undef_map",value="0x7188d0"}],file="dl-lookup.c",fullname="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377"},state="stopped",core="2"}],current-thread-id="2"
-1089threadnames 20
-1090python theDumper.fetchStack({"limit":20,"nativemixed":0,"token":1090})&"threadnames 20\n"
~"[]\n"
1089^done&"python
theDumper.fetchStack({"limit":20,"nativemixed":0,"token":1090})\n"~"frames=[frame={level="0",address="0x7f7bd9d7bd43",function="do_lookup_x",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="377",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="1",address="0x7f7bd9d7c94f",function="_dl_lookup_symbol_x",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-lookup.c",line="829",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="2",address="0x7f7bd9d7e5ad",function="elf_machine_rela",file="/build/glibc-GKVZIf/glibc-2.23/elf/../sysdeps/x86_64/dl-machine.h",line="301",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="3",address="0x7f7bd9d7e5ad",function="elf_dynamic_do_Rela",file="/build/glibc-GKVZIf/glibc-2.23/elf/do-rel.h",line="137",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="4",address="0x7f7bd9d7e5ad",function="_dl_relocate_object",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-reloc.c",line="258",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="5",address="0x7f7bd9d87681",function="dl_open_worker",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-open.c",line="435",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="6",address="0x7f7bd9d82394",function="_dl_catch_error",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-error.c",line="187",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="7",address="0x7f7bd9d86bd9",function="_dl_open",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-open.c",line="660",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="8",address="0x7f7bd9b6ef09",function="dlopen_doit",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlopen.c",line="66",module="/usr/lib/debug/lib/x86_64-linux-gnu/
libdl-2.23.so
",language="c"},frame={level="9",address="0x7f7bd9d82394",function="_dl_catch_error",file="/build/glibc-GKVZIf/glibc-2.23/elf/dl-error.c",line="187",module="/usr/lib/debug/lib/x86_64-linux-gnu/
ld-2.23.so
",language="c"},frame={level="10",address="0x7f7bd9b6f571",function="_dlerror_run",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlerror.c",line="163",module="/usr/lib/debug/lib/x86_64-linux-gnu/
libdl-2.23.so
",language="c"},frame={level="11",address="0x7f7bd9b6efa1",function="__dlopen",file="/build/glibc-GKVZIf/glibc-2.23/dlfcn/dlopen.c",line="87",module="/usr/lib/debug/lib/x86_64-linux-gnu/
libdl-2.23.so
",language="c"},frame={level="12",address="0x7f7bd937f174",function="load_ta",file="/home/r0ng/tools/OpenTEE/emulator/launcher/dynamic_loader.c",line="53",module="/home/r0ng/tools/OpenTEE/debug/libLauncherApi.so",language="c"},frame={level="13",address="0x7f7bd9383c47",function="ta_process_loop",file="/home/r0ng/tools/OpenTEE/emulator/launcher/ta_process.c",line="161",module="/home/r0ng/tools/OpenTEE/debug/libLauncherApi.so",language="c"},frame={level="14",address="0x7f7bd968eb5d",function="clone",file="/build/glibc-GKVZIf/glibc-2.23/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S",line="109",module="/usr/lib/debug/lib/x86_64-linux-gnu/
libc-2.23.so",language="c"}]\n"
1090^done
1091-stack-select-frame 12
1092python
theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["inspect","local","return","watch"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":1092,"typeformats":{},"watchers":[{"exp":"70617273655f746565635f726573756c7428726573756c7429","iname":"watch.0"},{"exp":"2a73657373696f6e436f6e74657874","iname":"watch.1"},{"exp":"28636861722a2970617468","iname":"watch.2"}]})1091^done
&"python
theDumper.fetchVariables({"autoderef":1,"context":"","displaystringlimit":"100","dyntype":1,"expanded":["inspect","local","return","watch"],"fancy":1,"formats":{},"nativemixed":0,"partialvar":"","passexceptions":0,"qobjectnames":0,"resultvarname":"","stringcutoff":"10000","token":1092,"typeformats":{},"watchers":[{"exp":"70617273655f746565635f726573756c7428726573756c7429","iname":"watch.0"},{"exp":"2a73657373696f6e436f6e74657874","iname":"watch.1"},{"exp":"28636861722a2970617468","iname":"watch.2"}]})\n"
~"data=[{iname="local.path",name="path",origaddr="0x707398",numchild="0",type="char
",valueencoded="utf8",value="2F686F6D652F72306E672F746F6F6C732F4F70656E5445452F64656275672F5441732F6C696274615F7363662E736F",address="0x7075b0",},{iname="local.callbacks",name="callbacks",origaddr="0x707390",numchild="0",origaddr="0x707390",type="ta_interface
*",value="0x0",address="0x7f7bd95873a0",},{iname="local.tmp_cb",name="tmp_cb",numchild="7",type="ta_interface",value="",address="0x7073f0",},{iname="local.err",name="err",numchild="0",type="char
*",value="0x0",address="0x7073a8",},{iname="local.internal_api_calls",name="internal_api_calls",numchild="7",type="internal_api_callbacks",value="",address="0x7073b0",},{iname="local.
*func",name="func",numchild="8",type="char
[8]",valueencoded="utf8",value="6C6F61645F746100",address="0x7f7bd93843f8",},{iname="watch.0",wname="70617273655F746565635F726573756C7428726573756C7429",numchild="0",type="
",value="",},{iname="watch.1",wname="2A73657373696F6E436F6E74657874",numchild="0",type="
",value="",},{iname="watch.2",wname="28636861722A2970617468",origaddr="0x707398",numchild="0",type="char
*",valueencoded="utf8",value="2F686F6D652F72306E672F746F6F6C732F4F70656E5445452F64656275672F5441732F6C696274615F7363662E736F",address="0x7075b0",},],typeinfo=[],partial="0"\n"
1092^done
Rebuild Watchmodel 55 @ 16:29:39.914 [20601ms]
sFinished retrieving data
Could anyone enlight me and let me what am I missed?
Thanks in advance
r0nG
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18, or mute the thread
https://github.com/notifications/unsubscribe-auth/AFbS3O3W-pp_EU8zUthH06QEFTt_F0Hsks5qXGBZgaJpZM4JPYrY
.
Hello Tanel,
Thanks for your reply. I defined an uuid in a common header file shared by both CA and TA:
#define SCF_UUID {0x123A567B, 0xB765, 0xA321, { 'B', 'I', 'G', 'E', 'S', 'T', '0', '0'}}
In the ta_scf.cpp
#ifdef TA_PLUGIN
#include "tee_ta_properties.h" /* Setting TA properties */
/* UUID must be unique */
SET_TA_PROPERTIES(
SCF_UUID,
512, // dataSize
255, // stackSize
1, // singletonInstance
1, // multiSession
1) // instanceKeepAlive
#endif // TA_PLUGIN
} // extern "C"
I also mentioned that if I removed opencv and relic libraries, the CA and TA works fine. So I do not think the segmentation fault is caused by property settings.
Thanks,
I am a bit puzzeled, because of the syslog. It is stating that propertie
section is not found, but you are receiving a segfault.. If I may ask,
could you search the propertie section from our TA binary after
compilation? E.g. "readelf -S our_ta_elf | grep .ta_properties".
-Tanel
2016-07-19 13:22 GMT+01:00 r0nG notifications@github.com:
Hello TanelDettenborn,
Thanks for your reply. I defined an uuid in a common header file:
#define SCF_UUID {0x123A567B, 0xB765, 0xA321, { 'B', 'I', 'G', 'E', 'S',
'T', '0', '0'}}In the ta_scf.cpp
#ifdef TA_PLUGIN
#include "tee_ta_properties.h" /* Setting TA properties *//* UUID must be unique */
SET_TA_PROPERTIES(
SCF_UUID,
512, // dataSize
255, // stackSize
1, // singletonInstance
1, // multiSession
- // instanceKeepAlive
#endif // TA_PLUGIN
} // extern "C"I also mentioned that if I removed opencv and relic libraries, the CA and
TA works fine. So I do not think the segmentation fault is caused by
property settings.Thanks,
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFbS3KQebJEy0izKKy3Zw-p3sknUJQVFks5qXMF6gaJpZM4JPYrY
.
Hello Tanel,
I run the cmd in Open-TEE/debug:
readelf -S libta_scf.so | grep .ta_properties
The result is:
[25] .ta_properties PROGBITS 00000000002ac720 000ac720
Hmm, I manually run a logrotate and tried to get the log again, it shows:
Jul 20 12:05:08 Lulu kernel: [ 7125.177214] libta_scf.so[808]: segfault at 31a ip 00007f2b54935d43 sp 00000000018a99a0 error 4 in ld-2.23.so[7f2b5492c000+26000]
And I put a breakpoint at dynamic_loader.c
tmp_cb.library = dlopen(path, RTLD_NOW);
the variable "path" has a correct location value of the libta_scf.so
Hi,
The log message that you posted:
Jul 19 15:55:09 Lulu tee_manager:
/home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:201
libta_scf.so : properties section is not found
Jul 19 15:55:09 Lulu tee_manager:
/home/r0ng/tools/OpenTEE/emulator/manager/ta_dir_watch.c:add_new_ta:227 TA
"libta_scf.so" rejected
Implies as Tanel said that the properties section seems not to be found.
But that should not cause a seg fault, it should print the warning and then
when a client tries to connect tot the TA you should get an error
indicating that the TA could not be found.
Looking at your make file it seems that you are mixing c and c++
(cpp.cxxLanguageVersion:"c++11"). The GP API is a C API so none of our
internal functionality is wrapped by
extern "C" {}
This means that c++ name mangling is an issue and as such this will cause
problems in dlopen and friends, which are written with C in mind.
It is true that the libtee client facing API could be wrapped in those
blocks to allow calling from C++ CAs, but internally this was never
conceived.
Can you give the output from straight from GDB after running the TA and it
seg faulting? On the GDB cmdline run: "thread apply all bt". Are the
libraries that you are trying to load c++ or C libraries?
Thanks,
Brian
On Wed, Jul 20, 2016 at 1:19 AM, r0nG notifications@github.com wrote:
Hello Tanel,
I run the cmd in Open-TEE/debug:
readelf -S libta_scf.so | grep .ta_properties
The result is:
[25] .ta_properties PROGBITS 00000000002ac720 000ac720
Is that mean I grabbed an incorrect syslog?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#18 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA_vJ-zho50oe3Ny_TKfOe2SCloCzNlvks5qXU10gaJpZM4JPYrY
.
Hello Brian & Tanel,
First thing first, thanks for your help. I found the code that causes the problem just now. It highly likely caused by our debug code.
Here is the "thread apply all bt" result:
<1634thread apply all bt
>&"thread apply all bt\n"
>~"\nThread 2.1 (Thread 0x7faad552b700 (LWP 17431)):\n"
>~"#0 do_lookup_x (undef_name=undef_name@entry=0x7faaca0598f8 \"_ITM_deregisterTMCloneTable\", new_hash=new_hash@entry=2247416213, old_hash=old_hash@entry=0xe31af0, ref=0x7faaca059390, result=result@entry=0xe31b00, scope=<optimized out>, i=0, version=0x0, flags=1, skip=0x0, type_class=4, undef_map=0xe43840) at dl-lookup.c:377\n"
>~"#1 0x00007faad533494f in _dl_lookup_symbol_x (undef_name=0x7faaca0598f8 \"_ITM_deregisterTMCloneTable\", undef_map=undef_map@entry=0xe43840, ref=ref@entry=0xe31c50, symbol_scope=symbol_scope@entry=0xe43b98, version=0x0, type_class=4, flags=1, skip_map=0x0) at dl-lookup.c:829\n"
>~"#2 0x00007faad53365ad in elf_machine_rela (skip_ifunc=0, reloc_addr_arg=0x7faaca25ffd8, version=<optimized out>, sym=0x7faaca059390, reloc=0x7faaca059df0, map=0xe43840) at ../sysdeps/x86_64/dl-machine.h:301\n"
>~"#3 elf_dynamic_do_Rela (skip_ifunc=0, lazy=<optimized out>, nrelative=<optimized out>, relsize=<optimized out>, reladdr=<optimized out>, map=0xe43840) at do-rel.h:137\n"
>~"#4 _dl_relocate_object (scope=<optimized out>, reloc_mode=reloc_mode@entry=0, consider_profiling=<optimized out>, consider_profiling@entry=0) at dl-reloc.c:258\n"
>~"#5 0x00007faad533f681 in dl_open_worker (a=a@entry=0xe320a0) at dl-open.c:435\n"
>~"#6 0x00007faad533a394 in _dl_catch_error (objname=objname@entry=0xe32090, errstring=errstring@entry=0xe32098, mallocedp=mallocedp@entry=0xe3208f, operate=operate@entry=0x7faad533f300 <dl_open_worker>, args=args@entry=0xe320a0) at dl-error.c:187\n"
>~"#7 0x00007faad533ebd9 in _dl_open (file=0xe32520 \"/home/r0ng/tools/OpenTEE/debug/TAs/libta_scf.so\", mode=-2147483646, caller_dlopen=0x7faad4937174 <load_ta+113>, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0x7fff5bff4028) at dl-open.c:660\n"
>~"#8 0x00007faad5126f09 in dlopen_doit (a=a@entry=0xe322d0) at dlopen.c:66\n"
>~"#9 0x00007faad533a394 in _dl_catch_error (objname=0xe280d0, errstring=0xe280d8, mallocedp=0xe280c8, operate=0x7faad5126eb0 <dlopen_doit>, args=0xe322d0) at dl-error.c:187\n"
>~"#10 0x00007faad5127571 in _dlerror_run (operate=operate@entry=0x7faad5126eb0 <dlopen_doit>, args=args@entry=0xe322d0) at dlerror.c:163\n"
>~"#11 0x00007faad5126fa1 in __dlopen (file=<optimized out>, mode=<optimized out>) at dlopen.c:87\n"
>~"#12 0x00007faad4937174 in load_ta (path=0xe32520 \"/home/r0ng/tools/OpenTEE/debug/TAs/libta_scf.so\", callbacks=0x7faad4b3f3a0 <interface>) at /home/r0ng/tools/OpenTEE/emulator/launcher/dynamic_loader.c:53\n"
>~"#13 0x00007faad493bc47 in ta_process_loop (arg=0x7fff5bff3bc0) at /home/r0ng/tools/OpenTEE/emulator/launcher/ta_process.c:161\n"
>~"#14 0x00007faad4c46b5d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109\n"
>1634^done
The opencv library highgui (libopencv_highgui.a) is used in the shared library TA libta_scf.so. We have code:
namedWindow("Show result", WINDOW_AUTOSIZE );
imshow("Show result", data);
waitKey(0);
The code is for creating a GUI window for the debugging purpose. If I remove the GUI code, the TA runs fine.
I know on OSX or Windows, all GUI related code must run in the main thread. Not sure the GUI rule on Ubuntu. Plus the TA is running on a separate process. Maybe, to invoke GUI code is not a good idea.
Hence, I checked the gdb 'info threads':
1841info threads
>&"info threads\n"
>~" Id Target Id Frame \n"
>~" 2.1 Thread 0x7fa828d58700 (LWP 18332) \"libta_scf.so\" 0x00007fa828474153 in epoll_wait () at ../sysdeps/unix/syscall-template.S:84\n"
>~"* 2.2 Thread 0x7fa823717700 (LWP 18336) \"libta_scf.so\" TA_CreateEntryPoint () at /home/r0ng/tools/OpenTEE/TAs/ta_scf/ta_scf.cpp:95\n"
>1841^done
The TA runs in the second thread. My guess is that is the cause of the problem.
My question is: is it possible that I could force the TA thread run in the main thread?
As to the issue of the shared library rejected. I found that I need to kill/restart the manager/launcher processes after the TA got modified. Sometimes I forgot to do that. Maybe I need some pre-build scripts to reset manager/launcher process, I know that is possible in visual studio but do think that is possible in qt creator.
For the language issue that Brian mentioned:
The library OpenCV is a c++ library; The library relic is a c library.
We use the C++ for TA, but I wrapped the Open-TEE framework headers in an 'extern "C" ' code block:
extern "C"
{
#include <stdlib.h>
#include <string.h>
// OpenTEE api
#include "tee_internal_api.h"
#include "tee_logging.h"
#ifdef TA_PLUGIN
#include "tee_ta_properties.h" /* Setting TA properties */
/* UUID must be unique */
SET_TA_PROPERTIES(
SCF_UUID,
512, // dataSize
255, // stackSize
1, // singletonInstance
1, // multiSession
1) // instanceKeepAlive
#endif // TA_PLUGIN
} // extern "C"
I believe that should be safe enough to call c function in c++ code, is that right?
Thank you very much,
r0nG
Maybe the framework could provide some extern interfaces so developers could create GUI for TA. Thanks for the helps :)