mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Breno" <brenosp@brasilsec.com.br>
To: "Kernel List" <linux-kernel@vger.kernel.org>
Subject: stack overflow
Date: Fri, 12 Sep 2003 18:53:58 +0100	[thread overview]
Message-ID: <002b01c37956$d88d67c0$f8e4a7c8@bsb.virtua.com.br> (raw)

Hi ... this is my idea to check a stack overflow. What do you think ?


#define STACK_LIMIT (1024*8192)/PAGE_SIZE

int check_stack_overflow(struct task_struct *tsk)
{

    unsigned long stack_size,stack_addr,stack_ptr;
    int i;

         if(tsk->mm != NULL)
         {
                  stack_addr = tsk->mm->start_stack;

                  stack_ptr = tsk->thread.esp;

                  for(i=0; i < stack_ptr; i++)
                  stack_addr++;

                  stack_size = (stack_addr - stack_ptr)/PAGE_SIZE;

                  if(stack_size > ( STACK_LIMIT - 1))
                  {
                               printk(KERN_CRIT"Process %s : pid %d -
                                Can cause stack
overflow\n",tsk->comm,tsk->pid);
                               return 0;
                  }
         }
return 0;
}

att,
Breno



             reply	other threads:[~2003-09-12 21:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12 17:53 Breno [this message]
2003-09-12 22:50 ` Andreas Dilger
2003-09-12 19:14   ` Breno
2003-09-12 23:06   ` William Lee Irwin III
2003-09-12 19:23     ` Breno
2003-09-12 23:18     ` Alan Cox
2003-09-12 23:25       ` William Lee Irwin III
2003-09-12 23:18         ` stack overflow - kernel thread Breno
  -- strict thread matches above, loose matches on Subject: below --
2003-01-24  7:08 Stack overflow Madhavi
2003-01-24  7:53 ` Linux Geek
2003-01-24 15:32   ` GrandMasterLee
2003-01-24 15:41     ` Madhavi
2003-01-24 16:42       ` Richard B. Johnson
2003-01-24 16:52       ` Gianni Tedesco

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='002b01c37956$d88d67c0$f8e4a7c8@bsb.virtua.com.br' \
    --to=brenosp@brasilsec.com.br \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®