0

I have a pointer to a data buffer in user space mode, and now I want to copy the value of that data to kernel mode with "copy_from_user" function.

Assume that my data pointer is "data.ptr.buffer" and it's size is "data_size". the declaration of "data.ptr.buffer" is : const void *buffer;

Now, how I can declare and allocate memory to it in kernel mode to get data buffer value in kernel mode? my "copy_from_user" call is something like :

copy_from_user(data_value, data.ptr.buffer, data_size)

In other words I want to know how I can declare data_value parameter and allocate memory to it (e.g kzalloc,...)?

Cert
  • 99
  • 1
  • 2
  • 9
  • 5
    You may want to look into `kmalloc()` which is the right thing to use if you just want some *arbitrary memory*. – tofro Apr 10 '16 at 20:32

1 Answers1

0

if you know your data size is small, say, a 100 byte, you could declare a char array. usigned char kernel_cmd_buf[129];