Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH] x86: suppress stack overrun message for init_task

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


JBeulich at novell

Nov 20, 2009, 6:00 AM

Post #1 of 4 (118 views)
Permalink
[PATCH] x86: suppress stack overrun message for init_task

init_task doesn't get its stack end location set to STACK_END_MAGIC,
and hence the message is confusing rather than helpful in this case.

Signed-off-by: Jan Beulich <jbeulich [at] novell>

---
arch/x86/mm/fault.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.32-rc8/arch/x86/mm/fault.c
+++ 2.6.32-rc8-x86-init-task-stack/arch/x86/mm/fault.c
@@ -658,7 +658,7 @@ no_context(struct pt_regs *regs, unsigne
show_fault_oops(regs, error_code, address);

stackend = end_of_stack(tsk);
- if (*stackend != STACK_END_MAGIC)
+ if (tsk != &init_task && *stackend != STACK_END_MAGIC)
printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");

tsk->thread.cr2 = address;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xiyou.wangcong at gmail

Nov 21, 2009, 2:17 AM

Post #2 of 4 (106 views)
Permalink
Re: [PATCH] x86: suppress stack overrun message for init_task [In reply to]

On Fri, Nov 20, 2009 at 02:00:14PM +0000, Jan Beulich wrote:
>init_task doesn't get its stack end location set to STACK_END_MAGIC,
>and hence the message is confusing rather than helpful in this case.
>
>Signed-off-by: Jan Beulich <jbeulich [at] novell>
>

Yeah, this is a good catch. STACK_END_MAGIC is written in fork(),
init is not forked.

However, isn't it better if we can do the same detection
for init too?


>---
> arch/x86/mm/fault.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>--- linux-2.6.32-rc8/arch/x86/mm/fault.c
>+++ 2.6.32-rc8-x86-init-task-stack/arch/x86/mm/fault.c
>@@ -658,7 +658,7 @@ no_context(struct pt_regs *regs, unsigne
> show_fault_oops(regs, error_code, address);
>
> stackend = end_of_stack(tsk);
>- if (*stackend != STACK_END_MAGIC)
>+ if (tsk != &init_task && *stackend != STACK_END_MAGIC)
> printk(KERN_ALERT "Thread overran stack, or stack corrupted\n");
>
> tsk->thread.cr2 = address;
>
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo [at] vger
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/

--
Live like a child, think like the god.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


xiyou.wangcong at gmail

Nov 21, 2009, 2:31 AM

Post #3 of 4 (105 views)
Permalink
Re: [PATCH] x86: suppress stack overrun message for init_task [In reply to]

On Fri, Nov 20, 2009 at 02:00:14PM +0000, Jan Beulich wrote:
>init_task doesn't get its stack end location set to STACK_END_MAGIC,
>and hence the message is confusing rather than helpful in this case.
>
>Signed-off-by: Jan Beulich <jbeulich [at] novell>
>

How about the patch below? It is totally untested. ;)

-------------->

init process should also write STACK_END_MAGIC to the
end of its stack.

Signed-off-by: WANG Cong <xiyou.wangcong [at] gmail>

----
diff --git a/init/main.c b/init/main.c
index 5988deb..5a8f1b9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -69,6 +69,7 @@
#include <linux/kmemtrace.h>
#include <linux/sfi.h>
#include <linux/shmem_fs.h>
+#include <linux/magic.h>
#include <trace/boot.h>

#include <asm/io.h>
@@ -798,7 +799,9 @@ static void __init do_pre_smp_initcalls(void)

static void run_init_process(char *init_filename)
{
+ unsigned long *stack_end = end_of_stack(&init_task);
argv_init[0] = init_filename;
+ *stack_end = STACK_END_MAGIC;
kernel_execve(init_filename, argv_init, envp_init);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


JBeulich at novell

Nov 23, 2009, 12:41 AM

Post #4 of 4 (103 views)
Permalink
Re: [PATCH] x86: suppress stack overrun message for init_task [In reply to]

>>> AméricoWang <xiyou.wangcong [at] gmail> 21.11.09 11:31 >>>
>On Fri, Nov 20, 2009 at 02:00:14PM +0000, Jan Beulich wrote:
>>init_task doesn't get its stack end location set to STACK_END_MAGIC,
>>and hence the message is confusing rather than helpful in this case.
>>
>>Signed-off-by: Jan Beulich <jbeulich [at] novell>
>>
>
>How about the patch below? It is totally untested. ;)
>
>-------------->
>
>init process should also write STACK_END_MAGIC to the
>end of its stack.

This seems way too late to me - in order to avoid any false reports, it
would really need to be part of INIT_TASK() I believe, but I didn't find
a way to make it so.

Jan

>Signed-off-by: WANG Cong <xiyou.wangcong [at] gmail>
>
>----
>diff --git a/init/main.c b/init/main.c
>index 5988deb..5a8f1b9 100644
>--- a/init/main.c
>+++ b/init/main.c
>@@ -69,6 +69,7 @@
> #include <linux/kmemtrace.h>
> #include <linux/sfi.h>
> #include <linux/shmem_fs.h>
>+#include <linux/magic.h>
> #include <trace/boot.h>
>
> #include <asm/io.h>
>@@ -798,7 +799,9 @@ static void __init do_pre_smp_initcalls(void)
>
> static void run_init_process(char *init_filename)
> {
>+ unsigned long *stack_end = end_of_stack(&init_task);
> argv_init[0] = init_filename;
>+ *stack_end = STACK_END_MAGIC;
> kernel_execve(init_filename, argv_init, envp_init);
> }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.