void cleanup_module(void) { printk(KERN_INFO "redir cleanup\n"); replace_syscall(__NR_chdir, orig_chdir); replace_syscall(__NR_stat, orig_stat); replace_syscall(__NR_lstat, orig_lstat); replace_syscall(__NR_access, orig_access); replace_syscall(__NR_open, orig_open); replace_syscall(__NR_readlink, orig_readlink); replace_syscall(__NR_getcwd, orig_getcwd); #if NEWVFS replace_syscall(__NR_stat64, orig_stat64); replace_syscall(__NR_lstat64, orig_lstat64); #endif #ifdef __i386__ replace_syscall(__NR_execve, orig_execve); #endif }
int init_module(void) { printk(KERN_INFO "redir init (version %s)\n", REDIR_VERSION); orig_chdir = replace_syscall(__NR_chdir, virt_chdir); orig_stat = replace_syscall(__NR_stat, virt_stat); orig_lstat = replace_syscall(__NR_lstat, virt_lstat); orig_access = replace_syscall(__NR_access, virt_access); orig_open = replace_syscall(__NR_open, virt_open); orig_readlink = replace_syscall(__NR_readlink, virt_readlink); orig_getcwd = replace_syscall(__NR_getcwd, virt_getcwd); #if NEWVFS orig_stat64 = replace_syscall(__NR_stat64, virt_stat64); orig_lstat64 = replace_syscall(__NR_lstat64, virt_lstat64); #endif #ifdef __i386__ orig_execve = replace_syscall(__NR_execve, virt_execve); #endif return 0; }
static void instruction_cb(unsigned char *pos, unsigned len, void *arg) { if (is_syscall_instr(pos, pos + len)) replace_syscall(pos, len); }