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

Snapshot use after free #2125

Merged
merged 4 commits into from
Mar 6, 2025
Merged

Conversation

PhilippTakacs
Copy link
Contributor

Fixes use after free on snapshots restore.

Also some cleanup in the unit tests. Mostly forgot to call uc_close.

The sanitizer also finds some stack overflow in test_x86_smc_add and test_x86_smc_mem_hook. I'm currently don't understand the error.

In test_context_snapshot of test_mem there is an Memory leak which I'm currently debug.

When restoring a snapshot with memory the flatview must be restored
before the memory reagions are filtered. Because the
AddressSpaceDispatcher also has pointer to the MemoryRegions and on copy
they need to be cleared. The memory_filter_subregions function frees
MemoryRegions which are not used at the time of the snapshot.
These tests has forgott to call uc_close(uc), which lead to memory
leaks. Found by the LeakSanitizer.
@PhilippTakacs
Copy link
Contributor Author

In test_context_snapshot of test_mem there is an Memory leak which I'm currently debug.

This is also fixed now.

@wtdcode
Copy link
Member

wtdcode commented Mar 6, 2025

The sanitizer also finds some stack overflow in test_x86_smc_add and test_x86_smc_mem_hook. I'm currently don't understand the error.

Noticed this and will fix too.

@wtdcode wtdcode merged commit 65ed715 into unicorn-engine:master Mar 6, 2025
38 checks passed
@wtdcode
Copy link
Member

wtdcode commented Mar 6, 2025

Thanks for the quick fix!

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.

2 participants