From d2971bb2511a96061467cc2276fdeae6b2bbd5e0 Mon Sep 17 00:00:00 2001 From: Yifan Lu Date: Wed, 5 Oct 2016 22:27:32 -0700 Subject: Fixed missing trampoline_size_left decrement for making initial trampoline jump Added comment about min exec page size requirement --- lib/hook-functions.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/hook-functions.c') diff --git a/lib/hook-functions.c b/lib/hook-functions.c index 8363567..5f71229 100644 --- a/lib/hook-functions.c +++ b/lib/hook-functions.c @@ -195,6 +195,7 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, initial_target = (uintptr_t) trampoline_ptr; make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr, (uintptr_t) hook->replacement, arch); + trampoline_size_left -= patch_size; } else { initial_target = (uintptr_t) hook->replacement; } @@ -211,6 +212,9 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks, if ((ret = execmem_alloc_unsealed(0, &trampoline_ptr, &trampoline_size_left))) goto end; + /* NOTE: We assume that each page is large enough (min 0x1000) + * so we don't lose a reference by having one hook allocate two + * pages. */ hi->trampoline_page = trampoline_ptr; } -- cgit v1.2.3