From: Frederik Deweerdt <deweerdt@free.fr>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Andrew Morton <akpm@osdl.org>,
"Andrew J. Barr" <andrew.james.barr@gmail.com>,
linux-kernel@vger.kernel.org, Jan Beulich <jbeulich@novell.com>,
Andi Kleen <ak@suse.de>,
"Eric W. Biederman" <ebiederm@xmission.com>,
walt <w41ter@gmail.com>
Subject: Re: [-mm patch] ptrace: Fix EFL_OFFSET value according to i386 pda changes (was Re: BUG on 2.6.20-rc1 when using gdb)
Date: Wed, 20 Dec 2006 20:42:26 +0000 [thread overview]
Message-ID: <20061220204226.GB28900@slug> (raw)
In-Reply-To: <45898D4E.1030507@goop.org>
On Wed, Dec 20, 2006 at 11:21:50AM -0800, Jeremy Fitzhardinge wrote:
> Frederik Deweerdt wrote:
> > Same problems here with 2.6.20-rc1-mm1 (ie with the %gs->%fs patch).
> > It seems to me that the problem comes from the EFL_OFFSET no longer
> > beeing accurate.
> > The following patch fixes the problem for me.
> >
>
> Thanks Frederik; that's exactly the kind of thing I thought it might
> be. I wonder if there's some way we can make this more robust
> though... Does this work for you? I did a slightly larger cleanup
> which should make it less fragile and more comprehensible.
>
It works too, thanks. BTW, I wondered if the "case GS:" in getreg() made
sense now?
Frederik
> J
>
> diff -r e775f6e42258 arch/i386/kernel/ptrace.c
> --- a/arch/i386/kernel/ptrace.c Tue Dec 19 10:32:40 2006 -0800
> +++ b/arch/i386/kernel/ptrace.c Wed Dec 20 11:18:56 2006 -0800
> @@ -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_
> }
>
> /*
> - * 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
> {
> 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 *ch
> }
> 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_
> 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 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/
>
next prev parent reply other threads:[~2006-12-20 20:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-18 1:55 BUG on 2.6.20-rc1 when using gdb Andrew J. Barr
2006-12-20 0:42 ` Andrew Morton
2006-12-20 0:53 ` Dave Airlie
2006-12-20 0:54 ` Dave Airlie
2006-12-20 11:21 ` Jeremy Fitzhardinge
2006-12-20 18:35 ` [-mm patch] ptrace: Fix EFL_OFFSET value according to i386 pda changes (was Re: BUG on 2.6.20-rc1 when using gdb) Frederik Deweerdt
2006-12-20 19:02 ` Andrew J. Barr
2006-12-20 19:21 ` Jeremy Fitzhardinge
2006-12-20 20:37 ` walt
2006-12-20 20:42 ` Frederik Deweerdt [this message]
2006-12-20 20:53 ` Jeremy Fitzhardinge
2006-12-20 21:07 ` Frederik Deweerdt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061220204226.GB28900@slug \
--to=deweerdt@free.fr \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=andrew.james.barr@gmail.com \
--cc=ebiederm@xmission.com \
--cc=jbeulich@novell.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=w41ter@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox