Allocating memory for user space from the kernel thread

My question is transferring data from the kernel to a user space program. I want to implement the system call "get_data (size, char * buff, char ** meta_buf)". In this call, the buff is allocated by the user space program, and its length is passed in the size argument. However, meta_buf is a variable-length buffer that is allocated (in the user space program of the vm page) and filled with the kernel. The user space program will free this area.

(I cannot allocate data in user space because the user space program does not know the size of meta_buff. In addition, the user space program cannot allocate a fixed amount of memory and call the system call again and again to read all metadata. Meta_data must be returned by one system call)

  • How can I allocate memory for a custom space program from a kernel thread? (I would even appreciate if you can point me to any other system call that performs a similar operation - allocation in the kernel and freeing in user space)
  • Is this interface correct or is there a better way to do this?
+5
source share
1 answer

- . :

  • , . , .
  • mmap-, , .
  • . .

, , . ( ), , ​​ . , , -.

+11

All Articles