Skip to content

Commit

Permalink
[PAL/Linux-SGX] Error out on enclave_dbginfo allocation failure
Browse files Browse the repository at this point in the history
We're modifying this structure dynamically since we introduced support
for dynamic TCS. The modification code in add_dynamic_tcs() has no way
of knowing whether the allocation failed or succeeded, thus it has no
way to decide whether writing there is legal or not.

This commit guarantees that the structure is always allocated.

Signed-off-by: Michał Kowalczyk <[email protected]>
  • Loading branch information
mkow authored and Dmitrii Kuvaiskii committed Aug 12, 2024
1 parent fb58e38 commit 0c0971c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pal/src/host/linux-sgx/host_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,9 @@ static int initialize_enclave(struct pal_enclave* enclave, const char* manifest_
/*fd=*/-1,
/*offset=*/0);
if (IS_PTR_ERR(dbg)) {
log_warning("Cannot allocate debug information (GDB will not work)");
log_error("Cannot allocate debug information for GDB");
ret = -ENOMEM;
goto out;
} else {
assert(dbg == (void*)DBGINFO_ADDR);
dbg->pid = g_host_pid;
Expand Down

0 comments on commit 0c0971c

Please sign in to comment.