Permalink
Browse files

Don't hijack already hijacked symbols

  • Loading branch information...
cormander committed Apr 23, 2012
1 parent 92e51e2 commit 4bec1f51f0813f60a2d55315fec3911f1390bb3e
Showing with 7 additions and 3 deletions.
  1. +7 −3 hijacks.c
View
@@ -173,6 +173,11 @@ int symbol_hijack(struct kernsym *sym, const char *symbol_name, unsigned long *c
if (IN_ERR(ret))
return ret;
+ if (*(u8 *)sym->addr == OP_JMP_REL32) {
+ printk(PKPRE "error: %s already appears to be hijacked\n", symbol_name);
+ return -EFAULT;
+ }
+
sym->new_addr = malloc(sym->size);
if (sym->new_addr == NULL) {
@@ -244,11 +249,10 @@ void symbol_restore(struct kernsym *sym) {
bool pte_ro;
- if (sym->new_addr)
- malloc_free(sym->new_addr);
-
if (sym->hijacked) {
+ malloc_free(sym->new_addr);
+
set_addr_rw((unsigned long) sym->addr, &pte_ro);
memcpy(sym->addr, &sym->orig_start_bytes[0], OP_JMP_SIZE);

0 comments on commit 4bec1f5

Please sign in to comment.