lkml.org 
[lkml]   [2005]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: 4k stacks
Date
From
Ok, I've come up with a patch to "poison"/mark the kernel stacks with Qs
when they're allocated. (I don't think it'll mark the IRQ stacks though).
I clear the marking before the stacks are freed. The patch should work
with any-sized stacks.

There is one wrinkle though: linux has struct thread_info at the bottom of
the kernel stacks, overwriting some of the Qs. stack.c needs to be modified
to skip the first sizeof(struct thread_info) bytes of a page.

DISCLAIMER: I am a novice kernel hacker: this patch may not perform as
advertised.

signed-off-by: <andrew.j.wade@gmail.com>

diff -uprN 2.6.15-rc5-mm3/kernel/fork.c ajw/kernel/fork.c
--- 2.6.15-rc5-mm3/kernel/fork.c 2005-12-26 01:07:57.087518486 -0500
+++ ajw/kernel/fork.c 2005-12-26 01:12:24.281198483 -0500
@@ -43,6 +43,7 @@
#include <linux/rmap.h>
#include <linux/acct.h>
#include <linux/cn_proc.h>
+#include <linux/string.h>

#include <asm/pgtable.h>
#include <asm/pgalloc.h>
@@ -102,6 +103,7 @@ static kmem_cache_t *mm_cachep;

void free_task(struct task_struct *tsk)
{
+ memset(tsk->thread_info, 0, THREAD_SIZE);
free_thread_info(tsk->thread_info);
free_task_struct(tsk);
}
@@ -171,6 +173,8 @@ static struct task_struct *dup_task_stru
return NULL;
}

+ memset(ti, 'Q', THREAD_SIZE);
+
*tsk = *orig;
tsk->thread_info = ti;
setup_thread_stack(tsk, orig);
-
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/
\
 
 \ /
  Last update: 2005-12-26 08:45    [W:0.067 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site