Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8701ea957dd2a7c309e17c8dcde3a64b92d8aec0
Commit:     8701ea957dd2a7c309e17c8dcde3a64b92d8aec0
Parent:     7c7e9425f114a109b07be2c2c1c6c169e34e9bb3
Author:     Jeremy Fitzhardinge <[EMAIL PROTECTED]>
AuthorDate: Fri Dec 22 01:11:21 2006 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Fri Dec 22 08:55:51 2006 -0800

    [PATCH] ptrace: Fix EFL_OFFSET value according to i386 pda changes
    
    The PDA patches introduced a bug in ptrace: it reads eflags from the wrong
    place on the target's stack, but writes it back to the correct place.  The
    result is a corrupted eflags, which is most visible when it turns interrupts
    off unexpectedly.
    
    This patch fixes this by making the ptrace code a little less fragile.  It
    changes [gs]et_stack_long to take a straightforward byte offset into struct
    pt_regs, rather than requiring all callers to do a sizeof(struct pt_regs)
    offset adjustment.  This means that the eflag's offset (EFL_OFFSET) on the
    target stack can be simply computed with offsetof().
    
    Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
    Cc: Frederik Deweerdt <[EMAIL PROTECTED]>
    Cc: Andi Kleen <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 arch/i386/kernel/ptrace.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index f3f94ac..af8aabe 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -45,7 +45,7 @@
 /*
  * Offset of eflags on child stack..
  */
-#define EFL_OFFSET ((EFL-2)*4-sizeof(struct pt_regs))
+#define EFL_OFFSET offsetof(struct pt_regs, eflags)
 
 static inline struct pt_regs *get_child_regs(struct task_struct *task)
 {
@@ -54,24 +54,24 @@ static inline struct pt_regs *get_child_regs(struct 
task_struct *task)
 }
 
 /*
- * this routine will get a word off of the processes privileged stack. 
- * the offset is how far from the base addr as stored in the TSS.  
- * this routine assumes that all the privileged stacks are in our
+ * This routine will get a word off of the processes privileged stack.
+ * the offset is bytes into the pt_regs structure on the stack.
+ * This routine assumes that all the privileged stacks are in our
  * data space.
  */   
 static inline int get_stack_long(struct task_struct *task, int offset)
 {
        unsigned char *stack;
 
-       stack = (unsigned char *)task->thread.esp0;
+       stack = (unsigned char *)task->thread.esp0 - sizeof(struct pt_regs);
        stack += offset;
        return (*((int *)stack));
 }
 
 /*
- * this routine will put a word on the processes privileged stack. 
- * the offset is how far from the base addr as stored in the TSS.  
- * this routine assumes that all the privileged stacks are in our
+ * This routine will put a word on the processes privileged stack.
+ * the offset is bytes into the pt_regs structure on the stack.
+ * This routine assumes that all the privileged stacks are in our
  * data space.
  */
 static inline int put_stack_long(struct task_struct *task, int offset,
@@ -79,7 +79,7 @@ static inline int put_stack_long(struct task_struct *task, 
int offset,
 {
        unsigned char * stack;
 
-       stack = (unsigned char *) task->thread.esp0;
+       stack = (unsigned char *)task->thread.esp0 - sizeof(struct pt_regs);
        stack += offset;
        *(unsigned long *) stack = data;
        return 0;
@@ -114,7 +114,7 @@ static int putreg(struct task_struct *child,
        }
        if (regno > ES*4)
                regno -= 1*4;
-       put_stack_long(child, regno - sizeof(struct pt_regs), value);
+       put_stack_long(child, regno, value);
        return 0;
 }
 
@@ -137,7 +137,6 @@ static unsigned long getreg(struct task_struct *child,
                default:
                        if (regno > ES*4)
                                regno -= 1*4;
-                       regno = regno - sizeof(struct pt_regs);
                        retval &= get_stack_long(child, regno);
        }
        return retval;
-
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