public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] oprofile, x86: Fix nmi-unsafe callgraph support in, 2.6.27  and later
@ 2011-06-13 13:40 John Lumby
  0 siblings, 0 replies; 8+ messages in thread
From: John Lumby @ 2011-06-13 13:40 UTC (permalink / raw)
  To: Robert Richter
  Cc: Maynard Johnson, oprofile list, mingo, peterz, linux-kernel list


On 06/09/11 08:57, Robert Richter wrote:
> On 08.06.11 13:43:56, John Lumby wrote:
>
> "EIP is at print_context_stack=0x45/0xb0
>
> and from a machine-code listing, I found that that offset corresponds
> to the line
>
>         addr = *stack;
>
> in arch/x86/kernel/dumpstack.c"
>
> Actually this should not happen, because of checking the stack pointer
> in valid_stack_ptr(). So could you apply the change below and test if
> this throws a bug message?

I applied that change and,  yes,  it throws the BUG :
     kernel BUG at arch/x86/kernel/dumpstack.c : 76!
It appears that the existing test in valid_stack_ptr makes too many assumptions 
about the other variables involved to catch all cases.

Also,   changing that test by adding a simplistic check for an absolute 
range is not sufficient,  as another crash then occurs in dump_trace at 
the line
        stack = (unsigned long *)context->previous_esp;

This patch to dumpstack_32.c seems to work for my system:
 (although it is probably more of a cover-up than a fix)

--- linux-2.6.39-FLG/arch/x86/kernel/dumpstack_32.c.orig    2011-05-19 
00:06:34.000000000 -0400
+++ linux-2.6.39-FLG/arch/x86/kernel/dumpstack_32.c    2011-06-12 
23:09:16.000000000 -0400
@@ -42,6 +42,19 @@ void dump_trace(struct task_struct *task

          context = (struct thread_info *)
              ((unsigned long)stack & (~(THREAD_SIZE - 1)));
+
+        /* crude bugcheck */
+        if (    ((unsigned long)stack <= 1024)
+             || ((unsigned long)stack >= 0xffffe000)
+             || ((unsigned long)context <= 1024)
+             || ((unsigned long)context >= 0xffffe000)
+                   ) {
+#ifdef NOISY_DUMP_TRACE
+             printk("dump_trace: pid %d stack= %p context= %p\n"
+                   ,(task ? task->pid : -1),stack,context);
+#endif  /* NOISY_DUMP_TRACE  */
+            break;
+                }
          bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);

          stack = (unsigned long *)context->previous_esp;


> Thanks,
>
> -Robert
>
>
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index e2a3f06..37693f5 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -73,6 +73,8 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
>                          void *p, unsigned int size, void *end)
>   {
>          void *t = tinfo;
> +
> +       BUG_ON(p<  (void *)THREAD_SIZE);
>          if (end) {
>                  if (p<  end&&  p>= (end-THREAD_SIZE))
>                          return 1;
>
 		 	   		  

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-07-21 19:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <COL116-W380DF5357514E3CC28BB66A38F0@phx.gbl>
     [not found] ` <4DD5046F.3000807@us.ibm.com>
     [not found]   ` <4DD53BC8.2010208@hotmail.com>
     [not found]     ` <20110607105259.GE20052@erda.amd.com>
     [not found]       ` <4DEE2F09.6090803@hotmail.com>
2011-06-07 17:18         ` [PATCH] oprofile, x86: Fix nmi-unsafe callgraph support in, 2.6.27 and later Robert Richter
2011-06-07 17:24           ` [RFC] [PATCH] x86: Make copy_from_user_nmi() a library function Robert Richter
2011-06-07 20:46             ` Cyrill Gorcunov
2011-07-05 17:22             ` Robert Richter
2011-07-05 17:40               ` Peter Zijlstra
2011-07-21 19:31             ` [tip:perf/core] x86, perf: " tip-bot for Robert Richter
     [not found]           ` <4DEFB4DC.7030206@hotmail.com>
2011-06-09 12:57             ` [PATCH] oprofile, x86: Fix nmi-unsafe callgraph support in, 2.6.27 and later Robert Richter
2011-06-13 13:40 John Lumby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox