Skip to content

Conversation

@0xd6cb6d73
Copy link

@0xd6cb6d73 0xd6cb6d73 commented Jan 28, 2026

The MappedModule class currently unconditionally calls VirtualFree on the module allocation when its destructor is called. This makes it fairly hard to use as the destructor will be called even if the object is moved.

This PR replaces the manual allocation with a std::unique_ptr<std::vector<std::byte>>. This makes the class safe to move.

Unfortunately, I noticed that this change broke TLS callbacks in some of the BOFs I tested when proper section protection was applied. This showed up as attempts to write in a stack region that didn't exist (anymore?). This issue went away when I made the entire allocation RWX. Therefore I also made UpdateSectionPermissions apply RWX on the entire buffer. I did notice that the protection wasn't always correctly applied when a RW section followed a non RW-section (.data after .text for ex.). Fixing this wasn't enough to prevent the aforementioned crash, hence the RWX.

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.

1 participant