| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com) | 
|  | 3 | * Licensed under the GPL | 
|  | 4 | */ | 
|  | 5 |  | 
|  | 6 | #include "linux/sched.h" | 
|  | 7 | #include "linux/shm.h" | 
| Adrian Bunk | cba4fbb | 2007-10-16 23:29:24 -0700 | [diff] [blame] | 8 | #include "linux/ipc.h" | 
| Al Viro | ff64b4c | 2008-08-18 04:01:47 -0400 | [diff] [blame] | 9 | #include "linux/syscalls.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include "asm/mman.h" | 
|  | 11 | #include "asm/uaccess.h" | 
|  | 12 | #include "asm/unistd.h" | 
|  | 13 |  | 
|  | 14 | /* | 
| Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 15 | * The prototype on i386 is: | 
|  | 16 | * | 
|  | 17 | *     int clone(int flags, void * child_stack, int * parent_tidptr, struct user_desc * newtls, int * child_tidptr) | 
|  | 18 | * | 
|  | 19 | * and the "newtls" arg. on i386 is read by copy_thread directly from the | 
|  | 20 | * register saved on the stack. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | */ | 
|  | 22 | long sys_clone(unsigned long clone_flags, unsigned long newsp, | 
| Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 23 | int __user *parent_tid, void *newtls, int __user *child_tid) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | { | 
|  | 25 | long ret; | 
|  | 26 |  | 
| Jeff Dike | e0877f0 | 2005-06-25 14:55:21 -0700 | [diff] [blame] | 27 | if (!newsp) | 
|  | 28 | newsp = UPT_SP(¤t->thread.regs.regs); | 
| Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 29 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | current->thread.forking = 1; | 
| Jeff Dike | e0877f0 | 2005-06-25 14:55:21 -0700 | [diff] [blame] | 31 | ret = do_fork(clone_flags, newsp, ¤t->thread.regs, 0, parent_tid, | 
|  | 32 | child_tid); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | current->thread.forking = 0; | 
| Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 34 | return ret; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } | 
|  | 36 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | long sys_sigaction(int sig, const struct old_sigaction __user *act, | 
|  | 38 | struct old_sigaction __user *oact) | 
|  | 39 | { | 
|  | 40 | struct k_sigaction new_ka, old_ka; | 
|  | 41 | int ret; | 
|  | 42 |  | 
|  | 43 | if (act) { | 
|  | 44 | old_sigset_t mask; | 
|  | 45 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || | 
|  | 46 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || | 
|  | 47 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) | 
|  | 48 | return -EFAULT; | 
|  | 49 | __get_user(new_ka.sa.sa_flags, &act->sa_flags); | 
|  | 50 | __get_user(mask, &act->sa_mask); | 
|  | 51 | siginitset(&new_ka.sa.sa_mask, mask); | 
|  | 52 | } | 
|  | 53 |  | 
|  | 54 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); | 
|  | 55 |  | 
|  | 56 | if (!ret && oact) { | 
|  | 57 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || | 
|  | 58 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || | 
|  | 59 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) | 
|  | 60 | return -EFAULT; | 
|  | 61 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags); | 
|  | 62 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask); | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | return ret; | 
|  | 66 | } |