Hello,
I'd like pass a pointer from a user space memory into a function in my kernel module. I don't want to use copy_from_user
. I've read that I should use get_user_pages
function.
For example one page.
struct page **pages;
pages = kmalloc(1 * sizeof(*pages), GFP_KERNEL);
down_read(¤t->mm->mmap_sem);
get_user_pages(current,current->mm,uaddr, 1, 1, 0,pages,NULL);
up_read(¤t->mm->mmap_sem);
uaddr
is an address in User Space.
- After doing this, am I allowed to cast and pass
uaddr
into my kernel module function? Or maybe I have to use thesestruct pages
in some way? - Why do I have to use down/up read?
- After everything do I have to use
SetPageDirty()
andpage_cache_release()
functions ?