Skip to content

Commit d212504

Browse files
author
Al Viro
committed
generic sys_fork / sys_vfork / sys_clone
... and get rid of idiotic struct pt_regs * in asm-generic/syscalls.h prototypes of the same, while we are at it. Eventually we want those in linux/syscalls.h, of course, but that'll have to wait a bit. Note that there are *three* variants of sys_clone() order of arguments. Braindamage galore... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 2590673 commit d212504

3 files changed

Lines changed: 60 additions & 4 deletions

File tree

‎arch/Kconfig‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,18 @@ config MODULES_USE_ELF_REL
341341
Modules only use ELF REL relocations. Modules with ELF RELA
342342
relocations will give an error.
343343

344+
#
345+
# ABI hall of shame
346+
#
347+
config CLONE_BACKWARDS
348+
bool
349+
help
350+
Architecture has tls passed as the 4th argument of clone(2),
351+
not the 5th one.
352+
353+
config CLONE_BACKWARDS2
354+
bool
355+
help
356+
Architecture has the first two arguments of clone(2) swapped.
357+
344358
source "kernel/gcov/Kconfig"

‎include/asm-generic/syscalls.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@
1010
*/
1111
#ifndef sys_clone
1212
asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
13-
void __user *parent_tid, void __user *child_tid,
14-
struct pt_regs *regs);
13+
void __user *parent_tid, void __user *child_tid);
1514
#endif
1615

1716
#ifndef sys_fork
18-
asmlinkage long sys_fork(struct pt_regs *regs);
17+
asmlinkage long sys_fork(void);
1918
#endif
2019

2120
#ifndef sys_vfork
22-
asmlinkage long sys_vfork(struct pt_regs *regs);
21+
asmlinkage long sys_vfork(void);
2322
#endif
2423

2524
#ifndef sys_execve

‎kernel/fork.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,6 +1645,49 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
16451645
}
16461646
#endif
16471647

1648+
#ifdef __ARCH_WANT_SYS_FORK
1649+
SYSCALL_DEFINE0(fork)
1650+
{
1651+
#ifdef CONFIG_MMU
1652+
return do_fork(SIGCHLD, 0, current_pt_regs(), 0, NULL, NULL);
1653+
#else
1654+
/* can not support in nommu mode */
1655+
return(-EINVAL);
1656+
#endif
1657+
}
1658+
#endif
1659+
1660+
#ifdef __ARCH_WANT_SYS_VFORK
1661+
SYSCALL_DEFINE0(vfork)
1662+
{
1663+
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, current_pt_regs(),
1664+
0, NULL, NULL);
1665+
}
1666+
#endif
1667+
1668+
#ifdef __ARCH_WANT_SYS_CLONE
1669+
#ifdef CONFIG_CLONE_BACKWARDS
1670+
SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1671+
int __user *, parent_tidptr,
1672+
int, tls_val,
1673+
int __user *, child_tidptr)
1674+
#elif defined(CONFIG_CLONE_BACKWARDS2)
1675+
SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
1676+
int __user *, parent_tidptr,
1677+
int __user *, child_tidptr,
1678+
int, tls_val)
1679+
#else
1680+
SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1681+
int __user *, parent_tidptr,
1682+
int __user *, child_tidptr,
1683+
int, tls_val)
1684+
#endif
1685+
{
1686+
return do_fork(clone_flags, newsp, current_pt_regs(), 0,
1687+
parent_tidptr, child_tidptr);
1688+
}
1689+
#endif
1690+
16481691
#ifndef ARCH_MIN_MMSTRUCT_ALIGN
16491692
#define ARCH_MIN_MMSTRUCT_ALIGN 0
16501693
#endif

0 commit comments

Comments
 (0)