Open pansilup opened 12 hours ago
Hello! Thank you for being interested in TDX. Regarding your questions:
The FS Base update is done in the VMCS only, with VMWRITE. Which means that it will have any effect only on the next SEAMCALL (on the same LP), so until the SEAMRET the current LP still runs with the same FSBASE that it started with.
Production TDX is built with the stack protector also.
0x28 is the default offset from FS that Clang 9 compiler is looking for when it builds a binary with stack protector.
Hi @sergey687, Thanks for the clarification. Cheers !!!
Summary: I have an issue related to the use of stack canaries in the TDX module's execution of the seamcall, TDH.SYS.LP.INIT. My analysis points to a scenario where canary validation at the end of tdh_sys_lp_init() fails when the FS base is changed in the middle of the function. I appreciate your help in clarifying this.
Background Information Considered:
Execution Sequence Suppose there are 2 LPs, LP0 and LP1. SEAMCALLs are issued sequentially.
Discussion: Consider the following binary code from libtdx.so applicable for tdh_sys_lp_init() function.
-My scenario pertains to the third SEAMCALL in the sequence above.
Questions: I have three questions:
Regarding Platform Initialization and Canary Validation: My real TDX platform does not have any issues with platform initialization, and I assume none of the other users are facing such issues either. However, based on the analysis above, it appears that the canary validation at the end of tdh_sys_lp_init() should fail on any LP where the very first SEAMCALL on the LP happens to be TDH.SYS.LP.INIT. Logically, this makes sense, as I’m under the impression that the FS base must not be changed in the middle of a function if the function includes stack canary operations at both the beginning and the end. Do you have any thoughts on this? Is there any part of my analysis where I might have gone astray?
About the libtdx.so Compilation: Is the production libtdx.so built without the fstack-protector-strong option?
About the Canary Location in sys-info Table: It seems that the canary value is initialized by TDH.SYS.INIT in a copy of the sys-info table, which is copied onto the last global data page. In the struct sysinfo_table_s, the offset of the canary is 0x28. This offset is consistent with the offset to the FS base we observer when the canary is referenced in libtdx.so. How does the compilation process know where (i.e., at an offset of 0x28 from the FS base) the TDX module stores the canary value?
Thank you.