lkm中调用system_call的问题
asmlinkage long fake_unlinkat(int dfd, const char *pathname, int flag)
{
int ret;
mm_segment_t fs;
char *path = "/root/hide/1";
char *pcomm = current->parent->comm;
if (strcmp(pcomm,"httpd") == 0 || strcmp(pcomm,"java") == 0 || strcmp(pcomm,"crond") == 0 || strcmp(pcomm,"bash") == 0)
{
fs = get_fs();
set_fs(KERNEL_DS);
ret = link(pathname,path); //link为sys_link系统调用
set_fs(fs);
printk("%d\n",ret);
}
return old_unlinkat(dfd,pathname,flag);
}
sys_link系统调用只接受char __user*的参数,使用set_fs(KERNEL_DS);放宽限制后,sys_link依然会返回EFAULT
跪求大神斧正,谢谢!!!
内核版本2.6.32