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

Failure with 0 aslr_slide #79

Open
liamwhite opened this issue Aug 15, 2023 · 1 comment
Open

Failure with 0 aslr_slide #79

liamwhite opened this issue Aug 15, 2023 · 1 comment

Comments

@liamwhite
Copy link

This code does not work when ASLR is disabled or you hit the 1/260000 lottery of selecting a 0 ASLR slide value:

// search for applicable space for inline hook JIT
auto cur_searching_addr =
skyline::utils::g_MainTextAddr - inline_hook_pool_size; // start searching from right before .text
MemoryInfo mem;
while (true) {
u32 page_info;
if (R_SUCCEEDED(svcQueryMemory(&mem, &page_info, cur_searching_addr)) && mem.type == MemType_Unmapped &&
mem.size >= ALIGN_UP(inline_hook_pool_size, PAGE_SIZE)) {
break;
}
cur_searching_addr -= PAGE_SIZE;
}
// allocate inline hook JIT
rc = jitCreate(&__inline_hook_jit, (void*)ALIGN_DOWN(mem.addr + mem.size - inline_hook_pool_size, PAGE_SIZE),
inline_hook_pool_size);

The code assumes addresses before the first .text section can be mapped as generated code. But if the ASLR slide is 0, then they are not mappable as generated code, and the program will fail to perform the call to svc::ControlCodeMemory and subsequently crash.

@jam1garner
Copy link
Member

I personally believe unlucky people should not be allowed to use Skyline

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

No branches or pull requests

2 participants