From: "Breno" <brenosp@brasilsec.com.br>
To: "William Lee Irwin III" <wli@holomorphy.com>,
"Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: stack overflow - kernel thread
Date: Sat, 13 Sep 2003 00:18:04 +0100 [thread overview]
Message-ID: <001701c37984$200442e0$f8e4a7c8@bsb.virtua.com.br> (raw)
In-Reply-To: <20030912232507.GV4306@holomorphy.com>
Hi .... this worked
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/unistd.h>
#include <linux/mm.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/highmem.h>
#include <linux/string.h>
#include <asm/uaccess.h>
#include <asm/errno.h>
#include <asm/mman.h>
#include <asm/page.h>
#include <asm/pgalloc.h>
#include <asm/processor.h>
#include <asm-i386/vm86.h>
#define THREAD 1
#define STACK_LIMIT 8192
int check_stack()
{
struct task_struct *p = NULL;
struct vm_area_struct *vma;
unsigned long stack_size, stack_addr, stack_ptr;
daemonize();
sprintf(current->comm,"CHECK_STACK");
for(;;schedule())
{
for_each_task(p)
{
if((p->mm != NULL) && (p->pid != 1))
{
stack_addr = p->mm->start_stack;
stack_ptr = p->thread.esp;
vma = find_vma(p->mm,stack_addr);
if(!vma)
return 0;
stack_size = (vma->vm_end - vma->vm_start)/PAGE_SIZE;
if(stack_size >= (STACK_LIMIT - 1024))
{
printk(KERN_CRIT"Process %s pid: %d\n",p->comm,p->pid);
printk(KERN_CRIT"Stack size %lu k\n",stack_size);
vma->vm_flags &= ~(VM_WRITE | VM_GROWSDOWN);
return 0;
}
}
}
}
return 0;
}
int init_module()
{
int th_pid[THREAD];
int i;
for(i = 0;i < THREAD;i++)
th_pid[i] = kernel_thread(check_stack,NULL,CLONE_SIGHAND);
if(th_pid[i] < 0)
printk(KERN_CRIT"Cannot create thread\n");
return 0;
}
void cleanup_module()
{
}
att,
Breno
----- Original Message -----
From: "William Lee Irwin III" <wli@holomorphy.com>
To: "Alan Cox" <alan@lxorguk.ukuu.org.uk>
Cc:
"Breno" <brenosp@brasilsec.com.br>; "Linux Kernel Mailing List"
<linux-kernel@vger.kernel.org>
Sent: Saturday, September 13, 2003 12:25 AM
Subject: Re: stack overflow
> On Sad, 2003-09-13 at 00:06, William Lee Irwin III wrote:
> >> What he actually wants is in-kernel user stack overflow checking, which
> >> is basically impossible since user stacks are demand paged. He's been
> >> told this before and failed to absorb it.
>
> On Sat, Sep 13, 2003 at 12:18:32AM +0100, Alan Cox wrote:
> > We will fault and error on a user stack exceed. You need to use
> > sigaltstack to catch it for obvious reasons. You can also use mmap and
> > drop in red zones on user space stacks
>
> Stack rlimits are fine and we already do those; the rest sounds like
> something userspace has to do.
>
>
> -- wli
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2003-09-13 3:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-12 17:53 stack overflow Breno
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 ` Breno [this message]
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='001701c37984$200442e0$f8e4a7c8@bsb.virtua.com.br' \
--to=brenosp@brasilsec.com.br \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=wli@holomorphy.com \
/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®