From: BlaisorBlade <blaisorblade_spam@yahoo.it>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Jeff Dike <jdike@addtoit.com>,
David Jeffery <djeffery@britsys.net>,
linux-kernel@vger.kernel.org
Subject: Re: [uml-devel] [PATCH] nptl/sys_clone fix for i386/ppc
Date: Sun, 12 Sep 2004 17:52:44 +0200 [thread overview]
Message-ID: <200409121752.07398.blaisorblade_spam@yahoo.it> (raw)
In-Reply-To: <20040911182615.GB2966@ccure.user-mode-linux.org>
[-- Attachment #1: Type: text/plain, Size: 2304 bytes --]
[For LKML: CC me on replies, I'm not subscribed]
On Saturday 11 September 2004 20:26, Jeff Dike wrote:
> > Jeff, please fix your patch again - the unused argument is the fourth,
> > not the third:
>
> Crap, I went to the trouble of confirming this in the i386 code, and
> ended up miscounting arguments. It still worked, though.
It worked no worse than current version (which is broken). In fact the 2.4
clone had 2 arguments. So it's obvious.
I checked in the i386 code (the _syscall5 macro and the sys_clone definition).
And the patch from David is the correct one:
This says where args go (from unistd.h, macro _syscall5):
: "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5))); \
And this is the i386 code, with some comments, especially about the three
remaining problems:
asmlinkage int sys_clone(struct pt_regs regs)
{
unsigned long clone_flags;
unsigned long newsp;
int __user *parent_tidptr, *child_tidptr;
clone_flags = regs.ebx; //arg1
newsp = regs.ecx; //arg2
parent_tidptr = (int __user *)regs.edx; //arg3
child_tidptr = (int __user *)regs.edi; //arg5
/*XXX: Shouldn't UML implement this?*/
if (!newsp)
newsp = regs.esp;
/*XXX: UML forgets the "& ~ CLONE_IDLETASK". */
/*And also UML does not pass regs.*/
return do_fork(clone_flags & ~CLONE_IDLETASK, newsp, ®s, 0,
parent_tidptr, child_tidptr);
}
Now, the CLONE_IDLETASK must be copied straight into our version. Pretty
clear, that flag is for kernelspace callers of do_fork() only.
Security problem? I guess possibly (in the meaning used by OpenBSD, i.e. it is
a security concern, because somehow could discover that this is exploitable).
Instead, luckily, both newsp and regs are passed unchanged to the arch code
(the arch-independent code ignores them), and exactly to copy_thread. And the
Uml version is ready to deal with this API, luckily.
However, this is non-standard. I've added just a comment for now, since you
may have reason to keep the current code, but such behaviour calls for
breakage when things change.
The attached patch replaces the one on your page.
--
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729
[-- Attachment #2: uml-fix-sys-clone-NPTL.patch --]
[-- Type: text/x-diff, Size: 2644 bytes --]
* Make sys_clone subarch-dependant
* Since i386 sys_clone skips reading %edi, the third param is unused
* Also, avoid passing to do_fork the CLONE_IDLETASK flag.
* Add a comment about the special calling convention used by UML for
do_fork and copy_thread.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
---
uml-linux-2.6.8.1-paolo/arch/um/kernel/syscall_kern.c | 11 ---------
uml-linux-2.6.8.1-paolo/arch/um/sys-i386/syscalls.c | 20 ++++++++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff -puN arch/um/kernel/syscall_kern.c~uml-fix-sys-clone-NPTL arch/um/kernel/syscall_kern.c
--- uml-linux-2.6.8.1/arch/um/kernel/syscall_kern.c~uml-fix-sys-clone-NPTL 2004-09-12 17:36:49.061595744 +0200
+++ uml-linux-2.6.8.1-paolo/arch/um/kernel/syscall_kern.c 2004-09-12 17:36:49.064595288 +0200
@@ -44,17 +44,6 @@ long sys_fork(void)
return(ret);
}
-long sys_clone(unsigned long clone_flags, unsigned long newsp,
- int *parent_tid, int *child_tid)
-{
- long ret;
-
- current->thread.forking = 1;
- ret = do_fork(clone_flags, newsp, NULL, 0, parent_tid, child_tid);
- current->thread.forking = 0;
- return(ret);
-}
-
long sys_vfork(void)
{
long ret;
diff -puN arch/um/sys-i386/syscalls.c~uml-fix-sys-clone-NPTL arch/um/sys-i386/syscalls.c
--- uml-linux-2.6.8.1/arch/um/sys-i386/syscalls.c~uml-fix-sys-clone-NPTL 2004-09-12 17:36:49.062595592 +0200
+++ uml-linux-2.6.8.1-paolo/arch/um/sys-i386/syscalls.c 2004-09-12 17:36:49.065595136 +0200
@@ -3,6 +3,7 @@
* Licensed under the GPL
*/
+#include "linux/sched.h"
#include "asm/mman.h"
#include "asm/uaccess.h"
#include "asm/unistd.h"
@@ -56,6 +57,25 @@ int old_select(struct sel_arg_struct *ar
return sys_select(a.n, a.inp, a.outp, a.exp, a.tvp);
}
+/* The i386 version skips reading from %esi, the fourth argument. So we must do
+ * this, too.*/
+int sys_clone(unsigned long clone_flags, unsigned long newsp, int *parent_tid,
+ int unused, int *child_tid)
+{
+ long ret;
+
+ /* XXX: normal arch do here this pass, and also pass the regs to do_fork,
+ * instead of NULL. Currently the arch-independent code ignores these
+ * values, while the UML code (actually it's copy_thread) does the right
+ * thing. But this should change, probably. */
+ /*if (!newsp)
+ newsp = UPT_SP(current->thread.regs);*/
+ current->thread.forking = 1;
+ ret = do_fork(clone_flags & ~CLONE_IDLETASK, newsp, NULL, 0, parent_tid, child_tid);
+ current->thread.forking = 0;
+ return(ret);
+}
+
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
_
next prev parent reply other threads:[~2004-09-12 17:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-26 2:06 [uml-devel] [PATCH] nptl/sys_clone fix for i386/ppc David Jeffery
2004-09-05 15:35 ` BlaisorBlade
2004-09-07 23:12 ` Michael Ralston
2004-09-10 23:52 ` Jeff Dike
2004-09-11 13:33 ` [uml-devel] " Sven Köhler
2004-09-11 14:18 ` Ralph Paßgang
2004-09-11 15:19 ` BlaisorBlade
2004-09-11 20:11 ` Sven Köhler
2004-09-12 18:19 ` BlaisorBlade
2004-09-11 15:45 ` [uml-devel] " BlaisorBlade
2004-09-11 18:26 ` Jeff Dike
2004-09-12 15:52 ` BlaisorBlade [this message]
2004-09-13 3:10 ` Jeff Dike
2004-09-13 18:50 ` BlaisorBlade
2004-09-12 15:54 ` [uml-devel] Unsent fixes by Andrew Morton BlaisorBlade
[not found] <BACKUPJQjdF8qoH28Db000022d5@NOSPAM.BRITSYS.NET>
2004-09-08 0:29 ` [uml-devel] [PATCH] nptl/sys_clone fix for i386/ppc David Jeffery
2004-09-08 18:09 ` BlaisorBlade
-- strict thread matches above, loose matches on Subject: below --
2004-09-11 22:27 Wichmann, Mats D
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=200409121752.07398.blaisorblade_spam@yahoo.it \
--to=blaisorblade_spam@yahoo.it \
--cc=djeffery@britsys.net \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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