Skip to content

Commit

Permalink
libsgxstep: fix remap memory leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovanbulck committed Apr 25, 2019
1 parent 0ce3066 commit e982624
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libsgxstep/pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ void *remap(uint64_t phys)
return (void*) virt;
}

void free_map(void *p)
{
ASSERT( !munmap((void*)(((uintptr_t) p) & ~PFN_MASK), 0x1000) );
}

void *remap_page_table_level( void *address, pt_level_t level )
{
address_mapping_t *map = get_mappings( address );
Expand Down Expand Up @@ -241,6 +246,7 @@ void print_pte_adrs( void *adrs)
uint64_t *pte = NULL;
ASSERT( pte = remap_page_table_level( adrs, PTE) );
print_pte(pte);
free_map(pte);
}

void print_pte( uint64_t *pte )
Expand Down
1 change: 1 addition & 0 deletions libsgxstep/pt.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void __attribute__((destructor)) tear_down_sgx_step( void );
typedef enum {PGD, PUD, PMD, PTE, PAGE} pt_level_t;

void *remap(uint64_t phys);
void free_map(void *p);
void *remap_page_table_level( void *address, pt_level_t level );
void flush_tlb(void *adrs);

Expand Down

0 comments on commit e982624

Please sign in to comment.