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

Create home space properly for Windows retpolines #322

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
if(PLATFORM_LINUX OR PLATFORM_MACOS)
option(UBPF_ENABLE_COVERAGE "Set to true to enable coverage flags")
option(UBPF_ENABLE_SANITIZERS "Set to true to enable the address and undefined sanitizers")
option(UBPF_DISABLE_RETPOLINES "Disable retpoline security on indirect calls and jumps")
else()
option(UBPF_DISABLE_RETPOLINES "Disable retpoline security on indirect calls and jumps" ON)
endif()

option(UBPF_DISABLE_RETPOLINES "Disable retpoline security on indirect calls and jumps")
option(UBPF_ENABLE_INSTALL "Set to true to enable the install targets")
option(UBPF_ENABLE_TESTS "Set to true to enable tests")
option(UBPF_ENABLE_PACKAGE "Set to true to enable packaging")
Expand Down
9 changes: 9 additions & 0 deletions vm/ubpf_jit_x86_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,22 @@ emit_retpoline(struct jit_state* state)
/* label2: */
/* call label0 */
uint32_t label2 = state->offset;
#if defined(_WIN32)
/*
* Make sure that *every* call in Windows has the home space.
*/
emit_alu64_imm32(state, 0x81, 5, RSP, 4 * sizeof(uint64_t));
#endif
emit1(state, 0xe8);
emit_jump_target_offset(state, state->offset, label0);
emit4(state, 0x00);

/*
* Before leaving this mini-function, restore the proper alignment (see above).
*/
#if defined(_WIN32)
emit_alu64_imm32(state, 0x81, 0, RSP, 4 * sizeof(uint64_t));
#endif
emit_alu64_imm32(state, 0x81, 0, RSP, sizeof(uint64_t));
emit_ret(state);

Expand Down
Loading