LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-18-2008, 07:40 AM   #1
evilsocket
LQ Newbie
 
Registered: Sep 2008
Posts: 1

Rep: Reputation: 0
Stack buffer size issue


Hello to all, i'm trying to develop a kernel module that accepts an ioctl with this structure :

Code:
typedef struct{
   /* [INPUT]  */
   long   process;
   unsigned long address;
     /* [OUTPUT] */      long mm_size;
}
mg_query_t;
where :

process : is the pid of a process .
address : is the address of a buffer on the stack of that process .

mm_size : *should* be the return value of the ioctl, indicating the size of that buffer, as an example (userspace test application):

Code:
char * abuffer[123];
mg_query_t query;
  query.process = getpid();
query.address = abuffer;
  if( ioctl( fd, IOCTL_MTABLE_BY_PID, &query ) < 0 ){
   close(fd);
   perror( "IOCTL_MTABLE_BY_PID" );
   return -1;
}
printf( "SIZE : %d\n", query.mm_size );



This *should* give the output :

SIZE : 123

I'm using the struct task_struct in the kernel module, looping the mmap to find the vm area the address resides in and then to set

mm_size = vm_end - vm_start

But doing so i obtaing only the size of the vm page the buffer resides .

Any hints ?

Thanks in advantage .
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
size of call stack? vkmgeek Programming 11 11-06-2006 09:42 AM
how to disable 4K stack size wahaha Linux - Wireless Networking 1 08-26-2006 06:33 AM
16K stack size in 2.6..xx quietguy47 Linux - Kernel 3 04-24-2006 01:21 PM
FC4 - new stack size? DJOtaku Fedora 2 10-07-2005 12:22 PM
Stack size decision atul_mehrotra Programming 2 10-08-2004 04:32 AM


All times are GMT -5. The time now is 05:27 AM.

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
Open Source Consulting | Domain Registration