From: Blaisorblade <blaisorblade@yahoo.it>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH consolidate sys_ptrace
Date: Fri, 11 Nov 2005 20:45:18 +0000 (UTC) [thread overview]
Message-ID: <loom.20051111T213148-66@post.gmane.org> (raw)
In-Reply-To: 20051102153143.5005a87b.akpm@osdl.org
Andrew Morton <akpm <at> osdl.org> writes:
>
> David Howells <dhowells <at> redhat.com> wrote:
> >
> > Christoph Hellwig <hch <at> lst.de> wrote:
> >
> > (1) Make a sys_ptrace() *jump* to arch_ptrace() instead of calling it, thus
> > obviating the extra return step.
> >
> If we can remove the lock_kernel() and move the final put_task_struct()
> into each arch_ptrace() then we can end sys_ptrace() with
> return arch_ptrace(....);
> and with luck, gcc will convert it into a tailcall for us.
Yep, it can do it, especially if CONFIG_REGPARM is enabled.
> It's probably not the first place to start doing such optimisation tho.
Boys, you risk being burned. I'm sorry I'll have to teach you a lesson. I'm
especially sorry because I had to learn it the hard way...
prevent_tail_call is there for a reason (grep for it in kernel/exit.c)
* If you do:
int do_foo(params...) {
...
}
asmlinkage int sys_foo(params...) {
return do_foo(a_new_param, params...);
}
* and do_foo and sys_foo have different prototypes (such as in the example or in
the patch),
THEN
GCC can reorder/change parameters of sys_foo on the stack, to make them match
the do_foo call.
Since those parameters are afterwards restored into userspace registers (which
are supposed to be unchanged), we get userspace breakage.
But only if userspace uses the registers afterwards, and if it calls with int
0x80 (there's no restoring otherwise, or something such).
I know this because I did once this exact error, and it was very hard to
diagnose (actually, it was in a UML-patch and I got breakage in UML). Also, it
was triggered only when CONFIG_REGPARM is enabled. If needed, I can point out
real examples (but you already should know).
next prev parent reply other threads:[~2005-11-11 20:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-01 5:09 [PATCH consolidate sys_ptrace Christoph Hellwig
2005-11-01 5:12 ` Christoph Hellwig
2005-11-01 9:51 ` Norbert Kiesel
2005-11-01 9:58 ` Paul Mackerras
2005-11-01 10:30 ` Ralf Baechle
2005-11-01 11:37 ` David Howells
2005-11-02 4:31 ` Andrew Morton
2005-11-11 20:45 ` Blaisorblade [this message]
2005-11-05 0:19 ` Christoph Hellwig
2005-11-01 18:12 ` Russell King
2005-11-02 11:21 ` Paul Mundt
-- strict thread matches above, loose matches on Subject: below --
2005-08-10 16:59 [PATCH] " Luck, Tony
2005-08-11 0:20 ` Stephen Rothwell
2005-08-10 8:00 Christoph Hellwig
2005-08-10 8:33 ` Martin Schwidefsky
2005-08-10 8:38 ` Christoph Hellwig
2005-08-10 8:43 ` Andi Kleen
2005-08-10 9:36 ` David Howells
2005-08-10 12:46 ` Paul Mundt
2005-08-10 13:15 ` Ralf Baechle
2005-08-10 13:28 ` Jeff Dike
2005-08-10 17:08 ` Richard Henderson
2005-08-11 10:44 ` Roman Zippel
2005-08-11 13:51 ` Christoph Hellwig
2005-08-11 16:51 ` Russell King
2005-08-11 17:32 ` Richard Henderson
2005-08-11 17:33 ` Christoph Hellwig
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=loom.20051111T213148-66@post.gmane.org \
--to=blaisorblade@yahoo.it \
--cc=linux-kernel@vger.kernel.org \
/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