How to allocate user space buffer in kernel driver?
c, linux, linux-device-driver, linux-kernel
Solution
There might be another way, depending on what system call you're actually trying to invoke.
Here is an article which explains a little bit about system call mechanics. There is a section which explains how to invoke system calls from kernel space, using kernel memory and avoid the validation.
mm_segment_t fs;
fs = get_fs(); /* save previous value */
set_fs (get_ds()); /* use kernel limit */
/* system calls can be invoked */
set_fs(fs); /* restore before returning to user space */
Problem
In some mess up i need to call one kernel function who is not suppose to call from kernel space because in argument it takes buffer from user space allocated. ``` const char __user *buf ``` But i need to call that so how can i allocate user space buffer and pass it with that function arguments. if possible then i need to do it without any user space interaction. Is it really possible? My goal is to call kernel routine from kernel driver who takes arguments `const char __user *buf`