我为execve系统调用编写了一个钩子,并在开始时将其编写为 print "hi",每次执行文件时。它工作正常,但是当我尝试打印filename传递给系统调用的内容时,这导致了崩溃,当然我不得不重新启动计算机。
这是我的代码:
static asmlinkage long our_execl(const char __user * filename,
const char __user * const __user * argv,
const char __user * const __user * envp) {
printk("%s\n",filename);
return original_execl(filename, argv, envp);
}
Run Code Online (Sandbox Code Playgroud)
这就是我注入新系统调用的方式:
static int lkm_example_init(void)
{
printk("new new new 2");
write_cr0(read_cr0()&(~ 0x10000));
sys_call_table = (void*)0xdd8c4240//the syscall address from the /proc/kallsyms ;
execl= sys_call_table[__NR_execve];
sys_call_table[__NR_execve]=our_execl;
write_cr0(read_cr0() | 0X10000);
return 0;
}
Run Code Online (Sandbox Code Playgroud)