From 5fd7026fc3cb9ae6bc62f507c60288cd4ffe727e Mon Sep 17 00:00:00 2001 From: Yu Yuan Date: Mon, 11 Dec 2017 21:56:40 +0800 Subject: [PATCH] Clear the heap pages after enclave initialization Signed-off-by: Yu Yuan --- sdk/trts/init_enclave.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/trts/init_enclave.cpp b/sdk/trts/init_enclave.cpp index 5317ab4a6..6a9718db0 100644 --- a/sdk/trts/init_enclave.cpp +++ b/sdk/trts/init_enclave.cpp @@ -154,8 +154,16 @@ sgx_status_t do_init_enclave(void *ms) { if (0 != accept_post_remove(&g_global_data.layout_table[0], &g_global_data.layout_table[0] + g_global_data.layout_entry_num, 0)) return SGX_ERROR_UNEXPECTED; + + size_t heap_min_size = get_heap_min_size(); + memset_s(GET_PTR(void, enclave_base, g_global_data.heap_offset), heap_min_size, 0, heap_min_size); } + else #endif + { + memset_s(GET_PTR(void, enclave_base, g_global_data.heap_offset), g_global_data.heap_size, 0, g_global_data.heap_size); + } + g_enclave_state = ENCLAVE_INIT_DONE; return SGX_SUCCESS; }