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
{
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
kernel编译时要加上-D__KERNEL_SYSCALLS__
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
install:
rmmod my_restore.ko 2>1& > /dev/null;insmod my_restore.ko
clean:
rm -f *.mod.c *.ko *.o我Makefile是这么写的,请问-D__KERNEL_SYSCALLS__应该如何加
新手,求大神指点
里面有相关示例,