Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=36ad4885c47c2187822f2783fb46fde2d36bf200
Commit:     36ad4885c47c2187822f2783fb46fde2d36bf200
Parent:     3b2b64fd311c92f2137eb7cee7025794cd854057
Author:     Linus Torvalds <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 31 20:18:51 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Aug 31 20:18:51 2007 -0700

    x86: be even more careful about checking the stack frame on dumping
    
    lguest didn't initialize the kernel stack the way a real i386 kernel
    does, and ended up triggering a corner-case in the stack frame checking
    that doesn't happen on naive i386, and that the stack dumping didn't
    handle quite right.
    
    This makes the frame handling more correct, and tries to clarify the
    code at the same time so that it's a bit more obvious what is going on.
    
    Thanks to Rusty Russell for debugging the lguest failure-
    
    Cc: Rusty Russell <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/i386/kernel/traps.c |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index cfffe3d..47b0bef 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -100,36 +100,45 @@ asmlinkage void machine_check(void);
 int kstack_depth_to_print = 24;
 static unsigned int code_bytes = 64;
 
-static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
+static inline int valid_stack_ptr(struct thread_info *tinfo, void *p, unsigned 
size)
 {
        return  p > (void *)tinfo &&
-               p < (void *)tinfo + THREAD_SIZE - 3;
+               p <= (void *)tinfo + THREAD_SIZE - size;
 }
 
+/* The form of the top of the frame on the stack */
+struct stack_frame {
+       struct stack_frame *next_frame;
+       unsigned long return_address;
+};
+
 static inline unsigned long print_context_stack(struct thread_info *tinfo,
                                unsigned long *stack, unsigned long ebp,
                                struct stacktrace_ops *ops, void *data)
 {
-       unsigned long addr;
-
 #ifdef CONFIG_FRAME_POINTER
-       while (valid_stack_ptr(tinfo, (void *)ebp)) {
-               unsigned long new_ebp;
-               addr = *(unsigned long *)(ebp + 4);
+       struct stack_frame *frame = (struct stack_frame *)ebp;
+       while (valid_stack_ptr(tinfo, frame, sizeof(*frame))) {
+               struct stack_frame *next;
+               unsigned long addr;
+
+               addr = frame->return_address;
                ops->address(data, addr);
                /*
                 * break out of recursive entries (such as
                 * end_of_stack_stop_unwind_function). Also,
                 * we can never allow a frame pointer to
                 * move downwards!
-                */
-               new_ebp = *(unsigned long *)ebp;
-               if (new_ebp <= ebp)
+                */
+               next = frame->next_frame;
+               if (next <= frame)
                        break;
-               ebp = new_ebp;
+               frame = next;
        }
 #else
-       while (valid_stack_ptr(tinfo, stack)) {
+       while (valid_stack_ptr(tinfo, stack, sizeof(*stack))) {
+               unsigned long addr;
+
                addr = *stack++;
                if (__kernel_text_address(addr))
                        ops->address(data, addr);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to