From 236e3a044ccb25aa48055f3e1f2ad24e0e113a80 Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Tue, 23 Nov 2021 15:19:21 +0000 Subject: [PATCH] Effectively zero TLS section on thread cleanup Signed-off-by: Amaury Chamayou --- enclave/core/sgx/threadlocal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enclave/core/sgx/threadlocal.c b/enclave/core/sgx/threadlocal.c index dcec5016bb..feb6e125c7 100644 --- a/enclave/core/sgx/threadlocal.c +++ b/enclave/core/sgx/threadlocal.c @@ -420,7 +420,11 @@ oe_result_t oe_thread_local_cleanup(oe_sgx_td_t* td) // (i.e., tls_start is NULL when tdata and tbss are zero). oe_allocator_thread_cleanup(); if (tls_start) - oe_memset_s(tls_start, (uint64_t)(fs - tls_start), 0, 0); + oe_memset_s( + tls_start, + (uint64_t)(fs - tls_start), + 0, + (uint64_t)(fs - tls_start)); return OE_OK; }