如何从其他用户地址space然后当前任务复制数据

How to copy data from other user address space then current task

我有创建内核线程的内核任务,我需要将数据从我的内核线程复制到调用我的内核任务的用户。所以我可以将当​​前任务作为参数传递给我的内核线程。 但是我如何告诉 copy_from_user 函数从其他进程地址 space 复制。 这是我的内核任务

 asmlinkage  int sys_daniel(struct pt_regs *r )
 {
       struct task_struct *ts1;
       ts1 = kthread_run(kthread_func, current, "thread-1");
       return 0;
   
  }

这是我要写的内核线程

static int kthread_func(struct_task args)
 {

   spcail_copy_to_user(from,to,len,args->mm)
  }

有任何方法可以编辑内核线程 current->mm 或在 copy_from_user 中设置地址 space。

好的,所以你首先需要用你想要的地址创建一个页面对象,所以我使用了

     struct page *P
     get_user_pages(current,current->mm,(unsigned long)buff,1,1,&p,NULL)

所以这基本上创建了页面,现在我们可以映射到内核 所以我们可以使用

kernlBuff=(char*)kmap(p);//mapping it to the kernel
kunmap(p);//for unmapp it from the kernel