Page 1 of 1 [ 4 posts ] 

Kurgan
Veteran
Veteran

User avatar

Joined: 6 Apr 2012
Age: 35
Gender: Male
Posts: 4,132
Location: Scandinavia

10 Nov 2013, 3:19 pm

On a lab task for my university, I have to pass a pointer to user space from kernel space and then read the memory address of that pointer. I've tried using copy_from_user(to, from, n), but all I get i "bad address" when I try to cat it. I've Googled all over the wb for an answer, but there are litteraly no good tutorials out there for this.



kicker
Velociraptor
Velociraptor

User avatar

Joined: 10 Oct 2013
Age: 45
Gender: Male
Posts: 467
Location: Atalnta, Ga

11 Nov 2013, 4:41 pm

User space memory <- Link

Sorry I won't help further, but everything you need to know can be found there or by using the information that is found there to get a better search result.



MyFutureSelfnMe
Veteran
Veteran

User avatar

Joined: 26 Feb 2010
Age: 44
Gender: Male
Posts: 1,385

14 Nov 2013, 12:57 pm

I assume this is on Linux.

You need to create a mapping of the memory into the process's own virtual address space. Like any process, the kernel has its own virtual address space and its pointers have no meaning in any user process. It's been a while for me, but I think you need to look up remap_pfn_range().

Don't copy the memory.



Kurgan
Veteran
Veteran

User avatar

Joined: 6 Apr 2012
Age: 35
Gender: Male
Posts: 4,132
Location: Scandinavia

15 Nov 2013, 1:09 pm

Thank you. I managed to solve the problem a few days ago, but both of your tips might come in handy for later work. :)