All of lore.kernel.org
 help / color / mirror / Atom feed
From: evilsocket <evilsocket@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Stack buffer size issue
Date: Thu, 18 Sep 2008 14:30:12 +0200	[thread overview]
Message-ID: <48D249D4.8000400@gmail.com> (raw)

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 .

             reply	other threads:[~2008-09-18 12:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-18 12:30 evilsocket [this message]
2008-09-18 17:36 ` Stack buffer size issue Valdis.Kletnieks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D249D4.8000400@gmail.com \
    --to=evilsocket@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.