You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After confirming that it was built normally, I intentionally caused an error by modifying the main.c file as follows.
main.c
int main(void)
{
TEEC_Result res;
TEEC_Context ctx;
TEEC_Session sess;
TEEC_Operation op;
TEEC_UUID uuid = TA_HELLO_WORLD_UUID;
uint32_t err_origin;
// whoops, forgot c strings are null-terminated
// and not enough memory was allocated for the copy
char *s = malloc(12);
strcpy(s, "Hello world!");
printf("string is: %s\n", s);
free(s);
...
}
As a result of the test, it was confirmed that the error occurred as follows.
# ./optee_example_hello_world
=================================================================
==240==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xffff8fc007bc at pc 0x00000041cdbc bp 0xfffffa0d8ba0 sp 0xfffffa0d8bf8
WRITE of size 13 at 0xffff8fc007bc thread T0
...
One curious thing is, optee_example_hello_world binary size has increased significantly. (14088->9785104)
I think it increased as libasan was statically included in the CA binary, is that correct?
Anyway, although it is in the title, the problem I am currently experiencing is that AddressSanitizer cannot be applied on the TA.
First of all, I looked at the link below and tried to add libasan to TA.
global-incdirs-y += include
srcs-y += hello_world_ta.c
# Adds the static library asan to the list of the linker directive -lasan.
libnames += asan
# Adds the directory path to the libraries pathes list. Archive file
# libasan.a is expected in this directory.
libdirs += <my optee home>/toolchains/aarch64/aarch64-none-linux-gnu/lib64
# To remove a certain compiler flag, add a line like this
cflags-template_ta.c-y += -fsanitize=address -static-libasan -g
Clients using libteec operate in Linux user space so the normal Linux user space based address sanitizer is expected to work without any OP-TEE specific changes.
However, TAs operates in a completely different environment so compiled Linux user space libraries can't be expected to work. In this case, I'm not sure if you even can re-use any of the libasan source code.
I would like to apply Address Sanitizer to CA and TA by referring to the link below.
Looking at config.mk of optee_os and the link below, it seems that sanitizer can be applied to optee-os(CFG_CORE_SANITIZE_KADDRESS).
As I said before, I plan to apply Sanitizer to CA and TA as well. For this, I used hello world in optee_example on QEMU v8.
First, I tried CA, and modified it as follows.
Makefile
After confirming that it was built normally, I intentionally caused an error by modifying the main.c file as follows.
main.c
As a result of the test, it was confirmed that the error occurred as follows.
One curious thing is, optee_example_hello_world binary size has increased significantly. (14088->9785104)
I think it increased as libasan was statically included in the CA binary, is that correct?
Anyway, although it is in the title, the problem I am currently experiencing is that AddressSanitizer cannot be applied on the TA.
First of all, I looked at the link below and tried to add libasan to TA.
sub.mk
Makefile
After modifying as above, the following error occurs when TA is built.
#901
I checked the above link, but I don't know what to do.
If anyone knows anything about this, please reply.
thank you
The text was updated successfully, but these errors were encountered: