The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > Linux
.
google unix.com



Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Heap fragementation on HPUX atgoel HP-UX 1 06-30-2009 01:44 PM
Heap and stack naan High Level Programming 5 04-30-2008 03:40 AM
AIX 5.3 Heap Memory with SAP johnf AIX 3 10-23-2006 06:21 AM
heap size for JVM! i2admin Filesystems, Disks and Memory 1 05-09-2002 10:09 AM
heap size! i2admin Filesystems, Disks and Memory 2 05-08-2002 11:20 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-16-2009
najoshi najoshi is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
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;
)
  #2 (permalink)  
Old 08-16-2009
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,972
I am hardly an expert in kernel code, but my understanding is there is a translation step between process addresses and kernel addresses.
  #3 (permalink)  
Old 08-17-2009
najoshi najoshi is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 2
No, copy_from_user( ) function does not require such logical to physical translation.
Reply

Bookmarks

Tags
copy_from_user, fail, heap

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0