lsds/TaLoS

Some memory not freed

InfiniteSamuel opened this issue · 2 comments

I recently discovered a bug. In /src/talos/patch/tasn_fre.c.patch::24, you have a #else macro, which is unnecessary. The code should be like this:

static void smart_free(void* ptr) {
#ifdef COMPILE_WITH_INTEL_SGX
	if (sgx_is_within_enclave(ptr, 1)) {
//#else
#endif
		free(ptr);
//#endif
#ifdef COMPILE_WITH_INTEL_SGX
	} else {
		ocall_free(ptr);
	}
#endif
}

Otherwise the ptr will not be freed.

Actually if you decrease the <HeapMaxSize>0x4600000</HeapMaxSize> by about 256 times in the enclave.config.xml, you will discover this bug soon enough.

Thank you for discovering this bug. Commit 1332eec fixes this issue.