I'm trying to call
sys_readlink(const char __user *path, char __user *buf, int bufsiz)
directly, but get EFAULT error code. This error appears because buf points to memory from kernel-space.
So, is there possible way to allocate user-space memory from kernel ?
kmalloc(size, GFP_USER)
is similar to kmalloc(size, GFP_KERNEL)
and returns pointer to kernel memory.
You can temporarily disable memory address validity checking by using set_fs
mm_segment_t old_fs;
old_fs = get_fs();
set_fs(KERNEL_DS);
/* Your syscall here */
set_fs(old_fs);