LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 08-16-2009, 12:09 AM   #1
najoshi
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
copy_from_user does not copy from process-heap


Hello all,

I need a positive reply from you.

I want to copy the user-process-heap to the kernel space memory.
For that, I wrote the following code but it does not copy.

---------------- code --------------
unsigned long length_of_heap_vma = < length of vma pointing to process-heap > ;
void * kernel_mem = (void *) kmalloc(length_of_heap_vma,GFP_KERNEL);

unsigned long bytes_not_copied = 0;


bytes_not_copied = copy_from_user(kernel_mem,(void *)vm->vma_start,length_of_heap_vma);//vm points to process heap
printk("failed to copy %ld bytes.",bytes_not_copied); //it always displays a non-zero value.

---------------- end of code --------

now the PROBLEM is that - the code successfuly compiles, but when I execute it, it copies not a single byte and
bytes_not-copied always becomes equal to length_of_heap_vma. No compile-time or execution-time error occurs.

(note: my process has the following dynamic memory in user-part:
int * p = (int*) malloc(5 * sizeof(int));
for(i=0;i<5;i++)
p[i]= i;
)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy_from_user() function fails inside a kernel thread. rajneesh.gaur Linux - Newbie 1 02-18-2012 04:58 PM
get the heap size from a specific process in linux powah Linux - General 3 01-04-2008 05:16 PM
Same address on heap for both child and parent process even after COPY_ON_WRITE?? piyush.kansal Programming 6 07-16-2007 10:26 AM
"wine: failed to create the process heap", in Fedora Core 2 crimsonmoon Linux - Software 3 06-16-2004 04:59 AM
Modifying the heap available to a process exitsfunnel Linux - Software 0 12-10-2003 09:20 PM


All times are GMT -5. The time now is 01:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration