OP-TEE / optee_os

Trusted side of the TEE
Other
1.51k stars 1.03k forks source link

core: fix undefined behavior aborts during xtest #6874

Open Abhishek-612 opened 3 weeks ago

Abhishek-612 commented 3 weeks ago
  1. Replace i64 with u64 in lib/libtomcrypt/tweetnacl.c to avoid shift_out_of_bounds error by UBSan.

  2. Add null pointer checks in kernel/user_access.c before memcpy to avoid nonnull_args error by UBSan.

Signed-off-by: Abhishek Revadekar abhishek.rvdkr@yahoo.com

Abhishek-612 commented 1 week ago

Hi, I tried analyzing the failed check (QEMUv8, Xen):

Below are the logs:

2024-06-07T02:22:57.2018600Z    export XEN_BOOT=y && \
2024-06-07T02:22:57.2018883Z    export XEN_FFA= && \
2024-06-07T02:22:57.2019136Z    export RUST_ENABLE=y && \
2024-06-07T02:22:57.2019682Z    expect /__w/optee_os/optee_repo_qemu_v8/build/../build/qemu-check.exp --  || \
2024-06-07T02:22:57.2020169Z    (if [ "" ]; then \
2024-06-07T02:22:57.2020424Z        echo "== $PWD/serial0.log:"; \
2024-06-07T02:22:57.2020869Z        cat serial0.log; \
2024-06-07T02:22:57.2021138Z        echo "== end of $PWD/serial0.log:"; \
2024-06-07T02:22:57.2021458Z        echo "== $PWD/serial1.log:"; \
2024-06-07T02:22:57.2021741Z        cat serial1.log; \
2024-06-07T02:22:57.2022005Z        echo "== end of $PWD/serial1.log:"; \
2024-06-07T02:22:57.2022311Z    fi; false)
2024-06-07T02:23:02.9572731Z Starting QEMU...!!! Kernel panic
2024-06-07T02:23:02.9593462Z make: *** [Makefile:588: check] Error 1
2024-06-07T02:23:03.1013090Z ##[error]Process completed with exit code 2.

Not sure if this issue was caused because of the patch. I tried running with and without undefined sanitizer: make run CFG_CORE_SANITIZE_UNDEFINED=y CFG_NS_VIRTUALIZATION=y make run CFG_NS_VIRTUALIZATION=y OPTEE OS booted without any issues, in both cases.

Is there any specific configuration the I am missing?

Would really appreciate any inputs that you might have!

Thanks! Abhishek

jenswi-linaro commented 1 week ago

Please try to rebase your branch on the latest.