Skip to content

Potential security issue by disabling W^X in the original function and the jit memory #89

@ZzzMao

Description

@ZzzMao

For functions in the memory, we usually have W^X protection to avoid buffer overflow attacking.

In the patch_function, it disabled the W^X first to be able to inject code to the original function address:

pub(crate) unsafe fn patch_function(func: *mut u8, patch: &[u8]) {
    make_memory_writable_and_executable(func); // <--------- HERE

    inject_asm_code(patch, func);
}

Should we consider doing it like this:

  • Change the memory page to Writable only (or Writable and Executable)
  • Inject the code.
  • Change the memory page to Executable only.

This idea also applies to the allocate_jit_memory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions