signal_32.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /* linux/arch/sparc/kernel/signal.c
  2. *
  3. * Copyright (C) 1991, 1992 Linus Torvalds
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
  6. * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
  7. */
  8. #include <linux/sched.h>
  9. #include <linux/kernel.h>
  10. #include <linux/signal.h>
  11. #include <linux/errno.h>
  12. #include <linux/wait.h>
  13. #include <linux/ptrace.h>
  14. #include <linux/unistd.h>
  15. #include <linux/mm.h>
  16. #include <linux/tty.h>
  17. #include <linux/smp.h>
  18. #include <linux/binfmts.h> /* do_coredum */
  19. #include <linux/bitops.h>
  20. #include <linux/tracehook.h>
  21. #include <asm/uaccess.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/pgalloc.h>
  24. #include <asm/pgtable.h>
  25. #include <asm/cacheflush.h> /* flush_sig_insns */
  26. #include <asm/switch_to.h>
  27. #include "sigutil.h"
  28. #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
  29. extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
  30. void *fpqueue, unsigned long *fpqdepth);
  31. extern void fpload(unsigned long *fpregs, unsigned long *fsr);
  32. struct signal_frame {
  33. struct sparc_stackf ss;
  34. __siginfo32_t info;
  35. __siginfo_fpu_t __user *fpu_save;
  36. unsigned long insns[2] __attribute__ ((aligned (8)));
  37. unsigned int extramask[_NSIG_WORDS - 1];
  38. unsigned int extra_size; /* Should be 0 */
  39. __siginfo_rwin_t __user *rwin_save;
  40. } __attribute__((aligned(8)));
  41. struct rt_signal_frame {
  42. struct sparc_stackf ss;
  43. siginfo_t info;
  44. struct pt_regs regs;
  45. sigset_t mask;
  46. __siginfo_fpu_t __user *fpu_save;
  47. unsigned int insns[2];
  48. stack_t stack;
  49. unsigned int extra_size; /* Should be 0 */
  50. __siginfo_rwin_t __user *rwin_save;
  51. } __attribute__((aligned(8)));
  52. /* Align macros */
  53. #define SF_ALIGNEDSZ (((sizeof(struct signal_frame) + 7) & (~7)))
  54. #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame) + 7) & (~7)))
  55. static int _sigpause_common(old_sigset_t set)
  56. {
  57. sigset_t blocked;
  58. current->saved_sigmask = current->blocked;
  59. set &= _BLOCKABLE;
  60. siginitset(&blocked, set);
  61. set_current_blocked(&blocked);
  62. current->state = TASK_INTERRUPTIBLE;
  63. schedule();
  64. set_thread_flag(TIF_RESTORE_SIGMASK);
  65. return -ERESTARTNOHAND;
  66. }
  67. asmlinkage int sys_sigsuspend(old_sigset_t set)
  68. {
  69. return _sigpause_common(set);
  70. }
  71. asmlinkage void do_sigreturn(struct pt_regs *regs)
  72. {
  73. struct signal_frame __user *sf;
  74. unsigned long up_psr, pc, npc;
  75. sigset_t set;
  76. __siginfo_fpu_t __user *fpu_save;
  77. __siginfo_rwin_t __user *rwin_save;
  78. int err;
  79. /* Always make any pending restarted system calls return -EINTR */
  80. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  81. synchronize_user_stack();
  82. sf = (struct signal_frame __user *) regs->u_regs[UREG_FP];
  83. /* 1. Make sure we are not getting garbage from the user */
  84. if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
  85. goto segv_and_exit;
  86. if (((unsigned long) sf) & 3)
  87. goto segv_and_exit;
  88. err = __get_user(pc, &sf->info.si_regs.pc);
  89. err |= __get_user(npc, &sf->info.si_regs.npc);
  90. if ((pc | npc) & 3)
  91. goto segv_and_exit;
  92. /* 2. Restore the state */
  93. up_psr = regs->psr;
  94. err |= __copy_from_user(regs, &sf->info.si_regs, sizeof(struct pt_regs));
  95. /* User can only change condition codes and FPU enabling in %psr. */
  96. regs->psr = (up_psr & ~(PSR_ICC | PSR_EF))
  97. | (regs->psr & (PSR_ICC | PSR_EF));
  98. /* Prevent syscall restart. */
  99. pt_regs_clear_syscall(regs);
  100. err |= __get_user(fpu_save, &sf->fpu_save);
  101. if (fpu_save)
  102. err |= restore_fpu_state(regs, fpu_save);
  103. err |= __get_user(rwin_save, &sf->rwin_save);
  104. if (rwin_save)
  105. err |= restore_rwin_state(rwin_save);
  106. /* This is pretty much atomic, no amount locking would prevent
  107. * the races which exist anyways.
  108. */
  109. err |= __get_user(set.sig[0], &sf->info.si_mask);
  110. err |= __copy_from_user(&set.sig[1], &sf->extramask,
  111. (_NSIG_WORDS-1) * sizeof(unsigned int));
  112. if (err)
  113. goto segv_and_exit;
  114. sigdelsetmask(&set, ~_BLOCKABLE);
  115. set_current_blocked(&set);
  116. return;
  117. segv_and_exit:
  118. force_sig(SIGSEGV, current);
  119. }
  120. asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
  121. {
  122. struct rt_signal_frame __user *sf;
  123. unsigned int psr, pc, npc;
  124. __siginfo_fpu_t __user *fpu_save;
  125. __siginfo_rwin_t __user *rwin_save;
  126. mm_segment_t old_fs;
  127. sigset_t set;
  128. stack_t st;
  129. int err;
  130. synchronize_user_stack();
  131. sf = (struct rt_signal_frame __user *) regs->u_regs[UREG_FP];
  132. if (!access_ok(VERIFY_READ, sf, sizeof(*sf)) ||
  133. (((unsigned long) sf) & 0x03))
  134. goto segv;
  135. err = __get_user(pc, &sf->regs.pc);
  136. err |= __get_user(npc, &sf->regs.npc);
  137. err |= ((pc | npc) & 0x03);
  138. err |= __get_user(regs->y, &sf->regs.y);
  139. err |= __get_user(psr, &sf->regs.psr);
  140. err |= __copy_from_user(&regs->u_regs[UREG_G1],
  141. &sf->regs.u_regs[UREG_G1], 15 * sizeof(u32));
  142. regs->psr = (regs->psr & ~PSR_ICC) | (psr & PSR_ICC);
  143. /* Prevent syscall restart. */
  144. pt_regs_clear_syscall(regs);
  145. err |= __get_user(fpu_save, &sf->fpu_save);
  146. if (!err && fpu_save)
  147. err |= restore_fpu_state(regs, fpu_save);
  148. err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
  149. err |= __copy_from_user(&st, &sf->stack, sizeof(stack_t));
  150. if (err)
  151. goto segv;
  152. regs->pc = pc;
  153. regs->npc = npc;
  154. /* It is more difficult to avoid calling this function than to
  155. * call it and ignore errors.
  156. */
  157. old_fs = get_fs();
  158. set_fs(KERNEL_DS);
  159. do_sigaltstack((const stack_t __user *) &st, NULL, (unsigned long)sf);
  160. set_fs(old_fs);
  161. err |= __get_user(rwin_save, &sf->rwin_save);
  162. if (!err && rwin_save) {
  163. if (restore_rwin_state(rwin_save))
  164. goto segv;
  165. }
  166. sigdelsetmask(&set, ~_BLOCKABLE);
  167. set_current_blocked(&set);
  168. return;
  169. segv:
  170. force_sig(SIGSEGV, current);
  171. }
  172. /* Checks if the fp is valid */
  173. static inline int invalid_frame_pointer(void __user *fp, int fplen)
  174. {
  175. if ((((unsigned long) fp) & 7) || !__access_ok((unsigned long)fp, fplen))
  176. return 1;
  177. return 0;
  178. }
  179. static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
  180. {
  181. unsigned long sp = regs->u_regs[UREG_FP];
  182. /*
  183. * If we are on the alternate signal stack and would overflow it, don't.
  184. * Return an always-bogus address instead so we will die with SIGSEGV.
  185. */
  186. if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
  187. return (void __user *) -1L;
  188. /* This is the X/Open sanctioned signal stack switching. */
  189. if (sa->sa_flags & SA_ONSTACK) {
  190. if (sas_ss_flags(sp) == 0)
  191. sp = current->sas_ss_sp + current->sas_ss_size;
  192. }
  193. sp -= framesize;
  194. /* Always align the stack frame. This handles two cases. First,
  195. * sigaltstack need not be mindful of platform specific stack
  196. * alignment. Second, if we took this signal because the stack
  197. * is not aligned properly, we'd like to take the signal cleanly
  198. * and report that.
  199. */
  200. sp &= ~15UL;
  201. return (void __user *) sp;
  202. }
  203. static int setup_frame(struct k_sigaction *ka, struct pt_regs *regs,
  204. int signo, sigset_t *oldset)
  205. {
  206. struct signal_frame __user *sf;
  207. int sigframe_size, err, wsaved;
  208. void __user *tail;
  209. /* 1. Make sure everything is clean */
  210. synchronize_user_stack();
  211. wsaved = current_thread_info()->w_saved;
  212. sigframe_size = sizeof(*sf);
  213. if (used_math())
  214. sigframe_size += sizeof(__siginfo_fpu_t);
  215. if (wsaved)
  216. sigframe_size += sizeof(__siginfo_rwin_t);
  217. sf = (struct signal_frame __user *)
  218. get_sigframe(&ka->sa, regs, sigframe_size);
  219. if (invalid_frame_pointer(sf, sigframe_size))
  220. goto sigill_and_return;
  221. tail = sf + 1;
  222. /* 2. Save the current process state */
  223. err = __copy_to_user(&sf->info.si_regs, regs, sizeof(struct pt_regs));
  224. err |= __put_user(0, &sf->extra_size);
  225. if (used_math()) {
  226. __siginfo_fpu_t __user *fp = tail;
  227. tail += sizeof(*fp);
  228. err |= save_fpu_state(regs, fp);
  229. err |= __put_user(fp, &sf->fpu_save);
  230. } else {
  231. err |= __put_user(0, &sf->fpu_save);
  232. }
  233. if (wsaved) {
  234. __siginfo_rwin_t __user *rwp = tail;
  235. tail += sizeof(*rwp);
  236. err |= save_rwin_state(wsaved, rwp);
  237. err |= __put_user(rwp, &sf->rwin_save);
  238. } else {
  239. err |= __put_user(0, &sf->rwin_save);
  240. }
  241. err |= __put_user(oldset->sig[0], &sf->info.si_mask);
  242. err |= __copy_to_user(sf->extramask, &oldset->sig[1],
  243. (_NSIG_WORDS - 1) * sizeof(unsigned int));
  244. if (!wsaved) {
  245. err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
  246. sizeof(struct reg_window32));
  247. } else {
  248. struct reg_window32 *rp;
  249. rp = &current_thread_info()->reg_window[wsaved - 1];
  250. err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
  251. }
  252. if (err)
  253. goto sigsegv;
  254. /* 3. signal handler back-trampoline and parameters */
  255. regs->u_regs[UREG_FP] = (unsigned long) sf;
  256. regs->u_regs[UREG_I0] = signo;
  257. regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
  258. regs->u_regs[UREG_I2] = (unsigned long) &sf->info;
  259. /* 4. signal handler */
  260. regs->pc = (unsigned long) ka->sa.sa_handler;
  261. regs->npc = (regs->pc + 4);
  262. /* 5. return to kernel instructions */
  263. if (ka->ka_restorer)
  264. regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
  265. else {
  266. regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
  267. /* mov __NR_sigreturn, %g1 */
  268. err |= __put_user(0x821020d8, &sf->insns[0]);
  269. /* t 0x10 */
  270. err |= __put_user(0x91d02010, &sf->insns[1]);
  271. if (err)
  272. goto sigsegv;
  273. /* Flush instruction space. */
  274. flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
  275. }
  276. return 0;
  277. sigill_and_return:
  278. do_exit(SIGILL);
  279. return -EINVAL;
  280. sigsegv:
  281. force_sigsegv(signo, current);
  282. return -EFAULT;
  283. }
  284. static int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
  285. int signo, sigset_t *oldset, siginfo_t *info)
  286. {
  287. struct rt_signal_frame __user *sf;
  288. int sigframe_size, wsaved;
  289. void __user *tail;
  290. unsigned int psr;
  291. int err;
  292. synchronize_user_stack();
  293. wsaved = current_thread_info()->w_saved;
  294. sigframe_size = sizeof(*sf);
  295. if (used_math())
  296. sigframe_size += sizeof(__siginfo_fpu_t);
  297. if (wsaved)
  298. sigframe_size += sizeof(__siginfo_rwin_t);
  299. sf = (struct rt_signal_frame __user *)
  300. get_sigframe(&ka->sa, regs, sigframe_size);
  301. if (invalid_frame_pointer(sf, sigframe_size))
  302. goto sigill;
  303. tail = sf + 1;
  304. err = __put_user(regs->pc, &sf->regs.pc);
  305. err |= __put_user(regs->npc, &sf->regs.npc);
  306. err |= __put_user(regs->y, &sf->regs.y);
  307. psr = regs->psr;
  308. if (used_math())
  309. psr |= PSR_EF;
  310. err |= __put_user(psr, &sf->regs.psr);
  311. err |= __copy_to_user(&sf->regs.u_regs, regs->u_regs, sizeof(regs->u_regs));
  312. err |= __put_user(0, &sf->extra_size);
  313. if (psr & PSR_EF) {
  314. __siginfo_fpu_t *fp = tail;
  315. tail += sizeof(*fp);
  316. err |= save_fpu_state(regs, fp);
  317. err |= __put_user(fp, &sf->fpu_save);
  318. } else {
  319. err |= __put_user(0, &sf->fpu_save);
  320. }
  321. if (wsaved) {
  322. __siginfo_rwin_t *rwp = tail;
  323. tail += sizeof(*rwp);
  324. err |= save_rwin_state(wsaved, rwp);
  325. err |= __put_user(rwp, &sf->rwin_save);
  326. } else {
  327. err |= __put_user(0, &sf->rwin_save);
  328. }
  329. err |= __copy_to_user(&sf->mask, &oldset->sig[0], sizeof(sigset_t));
  330. /* Setup sigaltstack */
  331. err |= __put_user(current->sas_ss_sp, &sf->stack.ss_sp);
  332. err |= __put_user(sas_ss_flags(regs->u_regs[UREG_FP]), &sf->stack.ss_flags);
  333. err |= __put_user(current->sas_ss_size, &sf->stack.ss_size);
  334. if (!wsaved) {
  335. err |= __copy_to_user(sf, (char *) regs->u_regs[UREG_FP],
  336. sizeof(struct reg_window32));
  337. } else {
  338. struct reg_window32 *rp;
  339. rp = &current_thread_info()->reg_window[wsaved - 1];
  340. err |= __copy_to_user(sf, rp, sizeof(struct reg_window32));
  341. }
  342. err |= copy_siginfo_to_user(&sf->info, info);
  343. if (err)
  344. goto sigsegv;
  345. regs->u_regs[UREG_FP] = (unsigned long) sf;
  346. regs->u_regs[UREG_I0] = signo;
  347. regs->u_regs[UREG_I1] = (unsigned long) &sf->info;
  348. regs->u_regs[UREG_I2] = (unsigned long) &sf->regs;
  349. regs->pc = (unsigned long) ka->sa.sa_handler;
  350. regs->npc = (regs->pc + 4);
  351. if (ka->ka_restorer)
  352. regs->u_regs[UREG_I7] = (unsigned long)ka->ka_restorer;
  353. else {
  354. regs->u_regs[UREG_I7] = (unsigned long)(&(sf->insns[0]) - 2);
  355. /* mov __NR_sigreturn, %g1 */
  356. err |= __put_user(0x821020d8, &sf->insns[0]);
  357. /* t 0x10 */
  358. err |= __put_user(0x91d02010, &sf->insns[1]);
  359. if (err)
  360. goto sigsegv;
  361. /* Flush instruction space. */
  362. flush_sig_insns(current->mm, (unsigned long) &(sf->insns[0]));
  363. }
  364. return 0;
  365. sigill:
  366. do_exit(SIGILL);
  367. return -EINVAL;
  368. sigsegv:
  369. force_sigsegv(signo, current);
  370. return -EFAULT;
  371. }
  372. static inline int
  373. handle_signal(unsigned long signr, struct k_sigaction *ka,
  374. siginfo_t *info, sigset_t *oldset, struct pt_regs *regs)
  375. {
  376. int err;
  377. if (ka->sa.sa_flags & SA_SIGINFO)
  378. err = setup_rt_frame(ka, regs, signr, oldset, info);
  379. else
  380. err = setup_frame(ka, regs, signr, oldset);
  381. if (err)
  382. return err;
  383. block_sigmask(ka, signr);
  384. tracehook_signal_handler(signr, info, ka, regs, 0);
  385. return 0;
  386. }
  387. static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
  388. struct sigaction *sa)
  389. {
  390. switch(regs->u_regs[UREG_I0]) {
  391. case ERESTART_RESTARTBLOCK:
  392. case ERESTARTNOHAND:
  393. no_system_call_restart:
  394. regs->u_regs[UREG_I0] = EINTR;
  395. regs->psr |= PSR_C;
  396. break;
  397. case ERESTARTSYS:
  398. if (!(sa->sa_flags & SA_RESTART))
  399. goto no_system_call_restart;
  400. /* fallthrough */
  401. case ERESTARTNOINTR:
  402. regs->u_regs[UREG_I0] = orig_i0;
  403. regs->pc -= 4;
  404. regs->npc -= 4;
  405. }
  406. }
  407. /* Note that 'init' is a special process: it doesn't get signals it doesn't
  408. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  409. * mistake.
  410. */
  411. static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
  412. {
  413. struct k_sigaction ka;
  414. int restart_syscall;
  415. sigset_t *oldset;
  416. siginfo_t info;
  417. int signr;
  418. /* It's a lot of work and synchronization to add a new ptrace
  419. * register for GDB to save and restore in order to get
  420. * orig_i0 correct for syscall restarts when debugging.
  421. *
  422. * Although it should be the case that most of the global
  423. * registers are volatile across a system call, glibc already
  424. * depends upon that fact that we preserve them. So we can't
  425. * just use any global register to save away the orig_i0 value.
  426. *
  427. * In particular %g2, %g3, %g4, and %g5 are all assumed to be
  428. * preserved across a system call trap by various pieces of
  429. * code in glibc.
  430. *
  431. * %g7 is used as the "thread register". %g6 is not used in
  432. * any fixed manner. %g6 is used as a scratch register and
  433. * a compiler temporary, but it's value is never used across
  434. * a system call. Therefore %g6 is usable for orig_i0 storage.
  435. */
  436. if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C))
  437. regs->u_regs[UREG_G6] = orig_i0;
  438. if (test_thread_flag(TIF_RESTORE_SIGMASK))
  439. oldset = &current->saved_sigmask;
  440. else
  441. oldset = &current->blocked;
  442. signr = get_signal_to_deliver(&info, &ka, regs, NULL);
  443. /* If the debugger messes with the program counter, it clears
  444. * the software "in syscall" bit, directing us to not perform
  445. * a syscall restart.
  446. */
  447. restart_syscall = 0;
  448. if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C)) {
  449. restart_syscall = 1;
  450. orig_i0 = regs->u_regs[UREG_G6];
  451. }
  452. if (signr > 0) {
  453. if (restart_syscall)
  454. syscall_restart(orig_i0, regs, &ka.sa);
  455. if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
  456. /* a signal was successfully delivered; the saved
  457. * sigmask will have been stored in the signal frame,
  458. * and will be restored by sigreturn, so we can simply
  459. * clear the TIF_RESTORE_SIGMASK flag.
  460. */
  461. if (test_thread_flag(TIF_RESTORE_SIGMASK))
  462. clear_thread_flag(TIF_RESTORE_SIGMASK);
  463. }
  464. return;
  465. }
  466. if (restart_syscall &&
  467. (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
  468. regs->u_regs[UREG_I0] == ERESTARTSYS ||
  469. regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
  470. /* replay the system call when we are done */
  471. regs->u_regs[UREG_I0] = orig_i0;
  472. regs->pc -= 4;
  473. regs->npc -= 4;
  474. pt_regs_clear_syscall(regs);
  475. }
  476. if (restart_syscall &&
  477. regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
  478. regs->u_regs[UREG_G1] = __NR_restart_syscall;
  479. regs->pc -= 4;
  480. regs->npc -= 4;
  481. pt_regs_clear_syscall(regs);
  482. }
  483. /* if there's no signal to deliver, we just put the saved sigmask
  484. * back
  485. */
  486. if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
  487. clear_thread_flag(TIF_RESTORE_SIGMASK);
  488. set_current_blocked(&current->saved_sigmask);
  489. }
  490. }
  491. void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
  492. unsigned long thread_info_flags)
  493. {
  494. if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
  495. do_signal(regs, orig_i0);
  496. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  497. clear_thread_flag(TIF_NOTIFY_RESUME);
  498. tracehook_notify_resume(regs);
  499. if (current->replacement_session_keyring)
  500. key_replace_session_keyring();
  501. }
  502. }
  503. asmlinkage int
  504. do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr,
  505. unsigned long sp)
  506. {
  507. int ret = -EFAULT;
  508. /* First see if old state is wanted. */
  509. if (ossptr) {
  510. if (put_user(current->sas_ss_sp + current->sas_ss_size,
  511. &ossptr->the_stack) ||
  512. __put_user(on_sig_stack(sp), &ossptr->cur_status))
  513. goto out;
  514. }
  515. /* Now see if we want to update the new state. */
  516. if (ssptr) {
  517. char *ss_sp;
  518. if (get_user(ss_sp, &ssptr->the_stack))
  519. goto out;
  520. /* If the current stack was set with sigaltstack, don't
  521. swap stacks while we are on it. */
  522. ret = -EPERM;
  523. if (current->sas_ss_sp && on_sig_stack(sp))
  524. goto out;
  525. /* Since we don't know the extent of the stack, and we don't
  526. track onstack-ness, but rather calculate it, we must
  527. presume a size. Ho hum this interface is lossy. */
  528. current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
  529. current->sas_ss_size = SIGSTKSZ;
  530. }
  531. ret = 0;
  532. out:
  533. return ret;
  534. }