Skip to content

Allocate executable JIT code to read+execute memory directly#7

Open
mafone wants to merge 2 commits into
wasm-ecosystem:developfrom
mafone:develop
Open

Allocate executable JIT code to read+execute memory directly#7
mafone wants to merge 2 commits into
wasm-ecosystem:developfrom
mafone:develop

Conversation

@mafone
Copy link
Copy Markdown

@mafone mafone commented Mar 9, 2026

This prevents a sensitive transition from read+write to read+execute

@mafone mafone requested a review from a team as a code owner March 9, 2026 15:28
@HerrCai0907 HerrCai0907 self-assigned this Mar 9, 2026
- Fix a sensitive transition from read+write to read+execute

On QNX, this prevents the acquisition of the prot_write_and_exec ability
Copy link
Copy Markdown
Author

@mafone mafone left a comment

Choose a reason for hiding this comment

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

To be validated:

Comment thread src/utils/MemUtils.cpp Outdated
Comment thread src/utils/MemUtils.cpp Outdated
int32_t error{ftruncate(jitCodeMapFile, static_cast<off_t>(alignedSize))};

if (error != 0) {
if ((error != 0) || (write(jitCodeMapFile, data, size) == -1)) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
if ((error != 0) || (write(jitCodeMapFile, data, size) == -1)) {
if ((error != 0) || (data == nullptr) || (write(jitCodeMapFile, data, size) == -1)) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

Comment thread src/utils/MemUtils.cpp Outdated
Comment thread src/utils/MemUtils.hpp
Comment thread src/utils/ExecutableMemory.cpp
Comment thread src/utils/MemUtils.cpp
// coverity[autosar_cpp14_a16_2_3_violation]
static_cast<int32_t>(syscall(__NR_memfd_create, ss.str().c_str(), MFD_CLOEXEC))}; // NOLINT(cppcoreguidelines-pro-type-vararg)
#elif defined __QNX__
int32_t const jitCodeMapFile{SHM_ANON, O_RDWR | O_CREAT, 0600)};
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
int32_t const jitCodeMapFile{SHM_ANON, O_RDWR | O_CREAT, 0600)};
int32_t const jitCodeMapFile{shm_open(SHM_ANON, O_RDWR | O_CREAT, 0600)};

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