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 | |
Al Viro | d2ce4e9 | 2012-09-20 09:28:25 -0400 | [diff] [blame] | 6 | #include <linux/syscalls.h> |
| 7 | #include <sysdep/syscalls.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | long sys_sigaction(int sig, const struct old_sigaction __user *act, |
| 10 | struct old_sigaction __user *oact) |
| 11 | { |
| 12 | struct k_sigaction new_ka, old_ka; |
| 13 | int ret; |
| 14 | |
| 15 | if (act) { |
| 16 | old_sigset_t mask; |
| 17 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || |
| 18 | __get_user(new_ka.sa.sa_handler, &act->sa_handler) || |
Al Viro | ffc51be | 2012-04-22 16:34:27 -0400 | [diff] [blame] | 19 | __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) || |
| 20 | __get_user(new_ka.sa.sa_flags, &act->sa_flags) || |
| 21 | __get_user(mask, &act->sa_mask)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | siginitset(&new_ka.sa.sa_mask, mask); |
| 24 | } |
| 25 | |
| 26 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
| 27 | |
| 28 | if (!ret && oact) { |
| 29 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || |
| 30 | __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || |
Al Viro | ffc51be | 2012-04-22 16:34:27 -0400 | [diff] [blame] | 31 | __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) || |
| 32 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || |
| 33 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | return ret; |
| 38 | } |