public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Stack buffer size issue
@ 2008-09-18 12:30 evilsocket
  2008-09-18 17:36 ` Valdis.Kletnieks
  0 siblings, 1 reply; 2+ messages in thread
From: evilsocket @ 2008-09-18 12:30 UTC (permalink / raw)
  To: linux-kernel

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

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):

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 .

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-18 17:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 12:30 Stack buffer size issue evilsocket
2008-09-18 17:36 ` Valdis.Kletnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox