Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 08-16-2009, 12:09 AM   #1
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));
p[i]= i;


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 > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:38 PM.

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