Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attestation: free JSON from the Wasm module heap #2803

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

JamesMenetrey
Copy link
Contributor

Dear developers,

The JSON evidence is allocated on the module instance heap, but no API was given to dispose of this memory buffer.
The sample mentions using the function free, which (I think) behaves differently depending on the execution context.
Typically, using the attestation API in a loop in a complex program (AOT) leads to a sudden stop of the program (without error output).

After investigation, I discovered that calling free in the Wasm app to dispose of the JSON evidence was the issue.
While the logic of memory allocation is quite complex to understand and have a full picture of it, my understanding is that calling free from the Wasm app may be different than calling the module_free macro in the runtime.
Since the JSON evidence is allocated using module_malloc, the corresponding free logic must be called accordingly.

This fix provides a new function called librats_dispose_evidence_json, enabling to free the JSON evidence directly from the Wasm app.

The JSON evidence is allocated on the module instance heap, but no API
was given to dispose of this memory buffer. The sample mentions using
the function free, which behaves differently depending on the
execution context.

This fix provides a new function called librats_dispose_evidence_json,
enabling freeing the JSON evidence directly from the Wasm app.
Copy link
Contributor

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wenyongh wenyongh merged commit f9e8b95 into bytecodealliance:main Nov 22, 2023
383 checks passed
@JamesMenetrey
Copy link
Contributor Author

Thanks! Quick question to follow up on this fix: could you please briefly describe how the malloc/free functions are mapped from the Wasm apps to the runtime? Is there a general handler for these functions we can inspect in the runtime to understand how the runtime handles them?

Thanks!

@wenyongh
Copy link
Contributor

victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
The JSON evidence is allocated on the module instance heap, but no API
was given to dispose of this memory buffer. The sample mentions using
the function free, which behaves differently depending on the
execution context.

This fix provides a new function called librats_dispose_evidence_json,
enabling freeing the JSON evidence directly from the Wasm app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants