Passing linked list via copy_from_user

自古美人都是妖i 提交于 2021-02-11 16:43:20

问题


I'm working on a linux project. I need to pass a linked list to the kernel from a userspace program. I have used the kernel way of implementing linked lists in userspace. I have defined a structure as follows:

struct time{ int val; struct list_head* list; };

The variable for this strucure would be:

struct time mylist;

I have given the input data and used list_add function found in linux/include/list.h to link the structures. This mylist is a part of another structure:

struct params{
int data1;
struct time* mylist;
};

Suppose I get all the data and store it in,

struct params param;

Now if I pass &param to a system call, and use copy_from_user() function there, will I be able to access the list ? I read that I cannot dereference a pointer in kernel space (which points to a data in userspace) and that I'll have to use copy_from_user function again in Linux Kernel: copy_from_user - struct with pointers. Could anyone suggest me a possible way of passing this list to the kernel space ?

来源:https://stackoverflow.com/questions/24408888/passing-linked-list-via-copy-from-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!