qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] User mode emulation's clone does not seem to work with glibc >= 2.4's fork
@ 2008-04-29 13:10 Lubomir Kundrak
  2008-04-29 13:55 ` Paul Brook
  0 siblings, 1 reply; 5+ messages in thread
From: Lubomir Kundrak @ 2008-04-29 13:10 UTC (permalink / raw)
  To: qemu-devel

I tried to run SH4 binaries linked with glibc-2.8 with qemu-sh4. fork()
system call was always returning with "Invalid argument".

Post glibc 2.3 fork() on Linux seems to call clone():

glibc-2.4/nptl/sysdeps/unix/sysv/linux/sh/fork.c:
 24 /* TLS pointer argument is passed as the 5-th argument.  */
 25 #define ARCH_FORK() \
 26   INLINE_SYSCALL (clone, 5,                                                   \
 27                   CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0,     \
 28                   NULL, &THREAD_SELF->tid, NULL)

qemu/linux-user/syscall.c:

2713 int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp)
...
2720     if (flags & CLONE_VM) {
...
2794     } else {
2795         /* if no CLONE_VM, we consider it is a fork */
2796         if ((flags & ~CSIGNAL) != 0)
2797             return -EINVAL;
2798         ret = fork();
2799     }
2800     return ret;

Here CLONE_CHILD_SETTID and CLONE_CHILD_CLEARTID being set cause the
~CSIGNAL conditional to fail. If the test is omited, some assertion fail
in glibc's fork() implementation is triggered.

-- 
Lubomir Kundrak (Red Hat Security Response Team)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-30 19:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-29 13:10 [Qemu-devel] User mode emulation's clone does not seem to work with glibc >= 2.4's fork Lubomir Kundrak
2008-04-29 13:55 ` Paul Brook
2008-06-30 16:57   ` [Qemu-devel] " michael
2008-06-30 19:23   ` michael
2008-06-30 19:55   ` michael

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).