Closed jan-kiszka closed 1 year ago
Hi @jan-kiszka,
It looks like the kernel is trying to do some TPM operation but tee-supplicant
is down already (and tee-supplicant
is needed by OP-TEE to access RPMB). We've encountered this on RockPi4 already. It was addressed by making sure the ftpm driver is unloaded before the supplicant is stopped, see https://gitlab.com/Linaro/trustedsubstrate/meta-ledge-secure/-/blob/kirkstone/meta-ledge-secure/recipes-security/optee/optee-client_%25.bbappend#L14. Ugly, but works.
A much better option would be to remove the dependency on tee-supplicant
for RPMB access (i.e., have the optee driver directly call kernel APIs to perform RPMB). See this discussion: https://lore.kernel.org/all/CAC_iWjLOhUvp5ggCCkHN5MRNfB_h6FZ2Z14yrtR3aqGn0Ovxig@mail.gmail.com/.
HTH.
OK, getting tee-supplicant daemon out of the way would also resolve the startup issues or the need to push it into initrd (see my post to LKML from yesterday).
We are currently compiling fTPM into the kernel, maybe worth to try avoiding that for now until that other issue is resolved.
Oh, follow-up question: Why are we getting those TA panics, rather than a normal error return to normal world? I'm also seeing that with avb triggered from u-boot (optee_rpmb read_pvalue somevalue 0
) - also ugly.
Oh, follow-up question: Why are we getting those TA panics, rather than a normal error return to normal world? I'm also seeing that with avb triggered from u-boot (
optee_rpmb read_pvalue somevalue 0
) - also ugly.
Because the TA receives TEE_ERROR_OUT_OF_MEMORY during a secure storage operation (RPC buffers that are normally allocated by tee-supplicant
). I don't know if the panic is called by the TA itself or in the GP API though (libutee). Could you symbolize the TA call stack? optee_os/scripts/symbolize.py -d path/to/TA/elf
(the path where bc50d971-d4c9-42c4-82cb-343fb7f37896.elf
can be found) then paste the E/...
lines.
Haven't done that for the fTPM yet (looking for the build folder...) but for the invalid call (pvalue size 0) to the in-tree avb:
E/TC:? 0
E/TC:? 0 TA panicked with code 0xffff0001 (TEE_ERROR_ACCESS_DENIED)
E/LD: Status of TA 023f8f1a-292a-432b-8fc4-de8471358067
E/LD: arch: aarch64
E/LD: region 0: va 0x40004000 pa 0x9ea00000 size 0x002000 flags rw-s (ldelf)
E/LD: region 1: va 0x40006000 pa 0x9ea02000 size 0x008000 flags r-xs (ldelf)
E/LD: region 2: va 0x4000e000 pa 0x9ea0a000 size 0x001000 flags rw-s (ldelf)
E/LD: region 3: va 0x4000f000 pa 0x9ea0b000 size 0x004000 flags rw-s (ldelf)
E/LD: region 4: va 0x40013000 pa 0x9ea0f000 size 0x001000 flags r--s
E/LD: region 5: va 0x40014000 pa 0x9ea2c000 size 0x005000 flags rw-s (stack)
E/LD: region 6: va 0x40019000 pa 0xfdf10cb0 size 0x001000 flags rw-- (param)
E/LD: region 7: va 0x4001a000 pa 0xfdf10c50 size 0x001000 flags rw-- (param)
E/LD: region 8: va 0x40070000 pa 0x00001000 size 0x014000 flags r-xs [0] .ta_head .text .eh_frame .rodata .gnu.hash .dynsym .dynstr .hash .rela.dyn
E/LD: region 9: va 0x40084000 pa 0x00015000 size 0x008000 flags rw-s [0] .dynamic .got .rela.got .data .bss
E/LD: [0] 023f8f1a-292a-432b-8fc4-de8471358067 @ 0x40070000 (out/arm-plat-k3/ta/avb/023f8f1a-292a-432b-8fc4-de8471358067.elf)
E/LD: Call stack:
E/LD: 0x400743e8 TEE_ReadObjectData at lib/libutee/tee_api_objects.c:915
E/LD: 0x400705f0 read_persist_value at ta/avb/entry.c:343
E/LD: 0x40075260 entry_invoke_command at lib/libutee/user_ta_entry.c:382
E/LD: 0x400707c8 __ta_entry at out/arm-plat-k3/export-ta_arm64/src/user_ta_header.c:70
Yep:
TEE_Result TEE_ReadObjectData(TEE_ObjectHandle object, void *buffer,
size_t size, size_t *count)
{
[...]
out:
if (res != TEE_SUCCESS &&
res != TEE_ERROR_CORRUPT_OBJECT &&
res != TEE_ERROR_STORAGE_NOT_AVAILABLE)
TEE_Panic(res);
Well...
OK, applying that rmmod workaround to tee-supplicant.service of Debian works around the original issue here as well. Thanks for that, but I hope we have a better solution until Debian 13 is out :wink:.
This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.
Issue is understood now, workarounds exist, but the proper solution is moving tee-supplicant into the kernel.
We are working on a full UEFI secure boot / RPMB secure storage integration on an AM65x (https://github.com/siemens/meta-iot2050), and one piece of the puzzle is an fTPM (https://github.com/Microsoft/ms-tpm-20-ref). Things are basically working, but this here is still at least annoying:
(I've added a WARN_ON to ftpm_tee_tpm_op_send's error path)
Any ideas? Where to debug this, in optee-os or rather the fTPM TA? I don't think the kernel is to blame (I've already checked the ftpm commits since 5.10 for anything suspicious).