X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fgears%2Fext_execve_hook.c;h=501b992504472171d08b72d2e78f0d571731af97;hb=d22c11cec4e8c3390bfe6bf16ed07f5d073f0d4a;hp=aa5bce266557b04f62ec58de2cffdf4836fe5894;hpb=7229981629c6baa0afb61cc99cfcf6dd029c9c93;p=palacios.releases.git diff --git a/palacios/src/gears/ext_execve_hook.c b/palacios/src/gears/ext_execve_hook.c index aa5bce2..501b992 100644 --- a/palacios/src/gears/ext_execve_hook.c +++ b/palacios/src/gears/ext_execve_hook.c @@ -56,27 +56,27 @@ static int init_exec_hooks (struct v3_vm_info * vm, v3_cfg_tree_t * cfg, void ** return 0; } -static int init_exec_hooks_core (struct guest_info * core, void * priv_data) { +static int init_exec_hooks_core (struct guest_info * core, void * priv_data, void ** core_data) { struct v3_exec_hooks * hooks = &exec_hooks; INIT_LIST_HEAD(&(hooks->hook_list)); hooks->bin_table = v3_create_htable(0, exec_hash_fn, exec_eq_fn); if (hooks->bin_table == NULL) { - PrintError("Problem creating execve hash table\n"); + PrintError(core->vm_info, core, "Problem creating execve hash table\n"); return -1; } if (core->cpu_mode == LONG || core->cpu_mode == LONG_32_COMPAT) { - PrintDebug("Hooking execve 64\n"); + PrintDebug(core->vm_info, core, "Hooking execve 64\n"); v3_hook_syscall(core, SYS64_EXECVE, v3_execve_handler, NULL); } else { - PrintDebug("Hooking execve, cpu mode: %x\n", core->cpu_mode); + PrintDebug(core->vm_info, core, "Hooking execve, cpu mode: %x\n", core->cpu_mode); v3_hook_syscall(core, SYS32_EXECVE, v3_execve_handler, NULL); } return 0; } -static int deinit_exec_hooks_core (struct guest_info * core, void * priv_data) { +static int deinit_exec_hooks_core (struct guest_info * core, void * priv_data, void * core_data) { struct v3_exec_hooks * hooks = &exec_hooks; struct exec_hook * hook = NULL; struct exec_hook * tmp = NULL; @@ -99,6 +99,11 @@ int v3_hook_executable (struct v3_vm_info * vm, struct exec_hook * hook = V3_Malloc(sizeof(struct exec_hook)); struct v3_exec_hooks * hooks = &exec_hooks; addr_t key; + + if (!hook) { + PrintError(vm, VCORE_NONE, "Cannot allocate in hooking exec\n"); + return -1; + } memset(hook, 0, sizeof(struct exec_hook)); @@ -124,12 +129,12 @@ int v3_unhook_executable (struct v3_vm_info * vm, const uchar_t * binfile) { if ((hook = (struct exec_hook*)v3_htable_search(hooks->bin_table, key)) != NULL) { free_hook(vm, hook); } else { - PrintError("Could not unhook executable '%s'\n", binfile); + PrintError(vm, VCORE_NONE, "Could not unhook executable '%s'\n", binfile); return -1; } if (v3_htable_remove(hooks->bin_table, key, 0) == (addr_t)NULL) { - PrintError("Error trying to remove key from htable: v3_unhook_executable\n"); + PrintError(vm, VCORE_NONE, "Error trying to remove key from htable: v3_unhook_executable\n"); return -1; } @@ -138,8 +143,8 @@ int v3_unhook_executable (struct v3_vm_info * vm, const uchar_t * binfile) { static struct v3_extension_impl execve_impl = { .name = "execve_intercept", - .init = init_exec_hooks, - .deinit = NULL, + .vm_init = init_exec_hooks, + .vm_deinit = NULL, .core_init = init_exec_hooks_core, .core_deinit = deinit_exec_hooks_core, .on_entry = NULL, @@ -164,7 +169,7 @@ int v3_execve_handler (struct guest_info * core, uint_t syscall_nr, void * priv_ } if (ret == -1) { - PrintError("Error translating file path in sysexecve handler\n"); + PrintError(core->vm_info, core, "Error translating file path in sysexecve handler\n"); return 0; } @@ -173,7 +178,7 @@ int v3_execve_handler (struct guest_info * core, uint_t syscall_nr, void * priv_ ret = hook->handler(core, hook->priv_data); if (ret == -1) { - PrintDebug("Error handling execve hook\n"); + PrintDebug(core->vm_info, core, "Error handling execve hook\n"); return -1; }