Skip to content

sgx reserved memory is not initialized #4648

@cmickeyb

Description

@cmickeyb

Thanks for filing a bug or defect report! Please fill out the TODOs below.

Subject of the issue

In os_mmap() in sgx_platform.c memory is allocated from sgx reserved memory. There is no guarantee that the memory will be zero'd out. In particular, this can be a problem if multiple execution environments are created (where reserved memory is allocated and then deallocated multiple times).

Test case

Not relevant.

Your environment

  • Ubuntu 24.04
  • WAMR 2.4.1 on SGX

Steps to reproduce

Create and destroy an execution environment repeatedly. The memory returned from SGX will have the data from the previous execution environment (it is not reset).

Expected behavior

Each invocation should be independent.

Actual behavior

Tell us what happens instead

Extra Info

A fairly simple memset on allocation solves the problem. A slightly more performant version which assumes the initial allocation is zero'd out memset's the memory when it is returned to the sgx reserved memory pool in munump.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions