signal_32.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * linux/arch/sh/kernel/signal.c
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. *
  6. * 1997-11-28 Modified for POSIX.1b signals by Richard Henderson
  7. *
  8. * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
  9. *
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/smp.h>
  14. #include <linux/kernel.h>
  15. #include <linux/signal.h>
  16. #include <linux/errno.h>
  17. #include <linux/wait.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/unistd.h>
  20. #include <linux/stddef.h>
  21. #include <linux/tty.h>
  22. #include <linux/elf.h>
  23. #include <linux/personality.h>
  24. #include <linux/binfmts.h>
  25. #include <linux/freezer.h>
  26. #include <linux/io.h>
  27. #include <linux/tracehook.h>
  28. #include <asm/ucontext.h>
  29. #include <asm/uaccess.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/cacheflush.h>
  32. #include <asm/syscalls.h>
  33. #include <asm/fpu.h>
  34. #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
  35. struct fdpic_func_descriptor {
  36. unsigned long text;
  37. unsigned long GOT;
  38. };
  39. /*
  40. * The following define adds a 64 byte gap between the signal
  41. * stack frame and previous contents of the stack. This allows
  42. * frame unwinding in a function epilogue but only if a frame
  43. * pointer is used in the function. This is necessary because
  44. * current gcc compilers (<4.3) do not generate unwind info on
  45. * SH for function epilogues.
  46. */
  47. #define UNWINDGUARD 64
  48. /*
  49. * Atomically swap in the new signal mask, and wait for a signal.
  50. */
  51. asmlinkage int
  52. sys_sigsuspend(old_sigset_t mask,
  53. unsigned long r5, unsigned long r6, unsigned long r7,
  54. struct pt_regs __regs)
  55. {
  56. sigset_t blocked;
  57. siginitset(&blocked, mask);
  58. return sigsuspend(&blocked);
  59. }
  60. asmlinkage int
  61. sys_sigaction(int sig, const struct old_sigaction __user *act,
  62. struct old_sigaction __user *oact)
  63. {
  64. struct k_sigaction new_ka, old_ka;
  65. int ret;
  66. if (act) {
  67. old_sigset_t mask;
  68. if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
  69. __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
  70. __get_user(new_ka.sa.sa_restorer, &act->sa_restorer))
  71. return -EFAULT;
  72. __get_user(new_ka.sa.sa_flags, &act->sa_flags);
  73. __get_user(mask, &act->sa_mask);
  74. siginitset(&new_ka.sa.sa_mask, mask);
  75. }
  76. ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
  77. if (!ret && oact) {
  78. if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
  79. __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
  80. __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer))
  81. return -EFAULT;
  82. __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
  83. __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
  84. }
  85. return ret;
  86. }
  87. asmlinkage int
  88. sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
  89. unsigned long r6, unsigned long r7,
  90. struct pt_regs __regs)
  91. {
  92. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  93. return do_sigaltstack(uss, uoss, regs->regs[15]);
  94. }
  95. /*
  96. * Do a signal return; undo the signal stack.
  97. */
  98. #define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
  99. #if defined(CONFIG_CPU_SH2)
  100. #define TRAP_NOARG 0xc320 /* Syscall w/no args (NR in R3) */
  101. #else
  102. #define TRAP_NOARG 0xc310 /* Syscall w/no args (NR in R3) */
  103. #endif
  104. #define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
  105. struct sigframe
  106. {
  107. struct sigcontext sc;
  108. unsigned long extramask[_NSIG_WORDS-1];
  109. u16 retcode[8];
  110. };
  111. struct rt_sigframe
  112. {
  113. struct siginfo info;
  114. struct ucontext uc;
  115. u16 retcode[8];
  116. };
  117. #ifdef CONFIG_SH_FPU
  118. static inline int restore_sigcontext_fpu(struct sigcontext __user *sc)
  119. {
  120. struct task_struct *tsk = current;
  121. if (!(boot_cpu_data.flags & CPU_HAS_FPU))
  122. return 0;
  123. set_used_math();
  124. return __copy_from_user(&tsk->thread.xstate->hardfpu, &sc->sc_fpregs[0],
  125. sizeof(long)*(16*2+2));
  126. }
  127. static inline int save_sigcontext_fpu(struct sigcontext __user *sc,
  128. struct pt_regs *regs)
  129. {
  130. struct task_struct *tsk = current;
  131. if (!(boot_cpu_data.flags & CPU_HAS_FPU))
  132. return 0;
  133. if (!used_math()) {
  134. __put_user(0, &sc->sc_ownedfp);
  135. return 0;
  136. }
  137. __put_user(1, &sc->sc_ownedfp);
  138. /* This will cause a "finit" to be triggered by the next
  139. attempted FPU operation by the 'current' process.
  140. */
  141. clear_used_math();
  142. unlazy_fpu(tsk, regs);
  143. return __copy_to_user(&sc->sc_fpregs[0], &tsk->thread.xstate->hardfpu,
  144. sizeof(long)*(16*2+2));
  145. }
  146. #endif /* CONFIG_SH_FPU */
  147. static int
  148. restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
  149. {
  150. unsigned int err = 0;
  151. #define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
  152. COPY(regs[1]);
  153. COPY(regs[2]); COPY(regs[3]);
  154. COPY(regs[4]); COPY(regs[5]);
  155. COPY(regs[6]); COPY(regs[7]);
  156. COPY(regs[8]); COPY(regs[9]);
  157. COPY(regs[10]); COPY(regs[11]);
  158. COPY(regs[12]); COPY(regs[13]);
  159. COPY(regs[14]); COPY(regs[15]);
  160. COPY(gbr); COPY(mach);
  161. COPY(macl); COPY(pr);
  162. COPY(sr); COPY(pc);
  163. #undef COPY
  164. #ifdef CONFIG_SH_FPU
  165. if (boot_cpu_data.flags & CPU_HAS_FPU) {
  166. int owned_fp;
  167. struct task_struct *tsk = current;
  168. regs->sr |= SR_FD; /* Release FPU */
  169. clear_fpu(tsk, regs);
  170. clear_used_math();
  171. __get_user (owned_fp, &sc->sc_ownedfp);
  172. if (owned_fp)
  173. err |= restore_sigcontext_fpu(sc);
  174. }
  175. #endif
  176. regs->tra = -1; /* disable syscall checks */
  177. err |= __get_user(*r0_p, &sc->sc_regs[0]);
  178. return err;
  179. }
  180. asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
  181. unsigned long r6, unsigned long r7,
  182. struct pt_regs __regs)
  183. {
  184. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  185. struct sigframe __user *frame = (struct sigframe __user *)regs->regs[15];
  186. sigset_t set;
  187. int r0;
  188. /* Always make any pending restarted system calls return -EINTR */
  189. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  190. if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
  191. goto badframe;
  192. if (__get_user(set.sig[0], &frame->sc.oldmask)
  193. || (_NSIG_WORDS > 1
  194. && __copy_from_user(&set.sig[1], &frame->extramask,
  195. sizeof(frame->extramask))))
  196. goto badframe;
  197. sigdelsetmask(&set, ~_BLOCKABLE);
  198. set_current_blocked(&set);
  199. if (restore_sigcontext(regs, &frame->sc, &r0))
  200. goto badframe;
  201. return r0;
  202. badframe:
  203. force_sig(SIGSEGV, current);
  204. return 0;
  205. }
  206. asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
  207. unsigned long r6, unsigned long r7,
  208. struct pt_regs __regs)
  209. {
  210. struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
  211. struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs->regs[15];
  212. sigset_t set;
  213. int r0;
  214. /* Always make any pending restarted system calls return -EINTR */
  215. current_thread_info()->restart_block.fn = do_no_restart_syscall;
  216. if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
  217. goto badframe;
  218. if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
  219. goto badframe;
  220. sigdelsetmask(&set, ~_BLOCKABLE);
  221. set_current_blocked(&set);
  222. if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
  223. goto badframe;
  224. if (do_sigaltstack(&frame->uc.uc_stack, NULL,
  225. regs->regs[15]) == -EFAULT)
  226. goto badframe;
  227. return r0;
  228. badframe:
  229. force_sig(SIGSEGV, current);
  230. return 0;
  231. }
  232. /*
  233. * Set up a signal frame.
  234. */
  235. static int
  236. setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
  237. unsigned long mask)
  238. {
  239. int err = 0;
  240. #define COPY(x) err |= __put_user(regs->x, &sc->sc_##x)
  241. COPY(regs[0]); COPY(regs[1]);
  242. COPY(regs[2]); COPY(regs[3]);
  243. COPY(regs[4]); COPY(regs[5]);
  244. COPY(regs[6]); COPY(regs[7]);
  245. COPY(regs[8]); COPY(regs[9]);
  246. COPY(regs[10]); COPY(regs[11]);
  247. COPY(regs[12]); COPY(regs[13]);
  248. COPY(regs[14]); COPY(regs[15]);
  249. COPY(gbr); COPY(mach);
  250. COPY(macl); COPY(pr);
  251. COPY(sr); COPY(pc);
  252. #undef COPY
  253. #ifdef CONFIG_SH_FPU
  254. err |= save_sigcontext_fpu(sc, regs);
  255. #endif
  256. /* non-iBCS2 extensions.. */
  257. err |= __put_user(mask, &sc->oldmask);
  258. return err;
  259. }
  260. /*
  261. * Determine which stack to use..
  262. */
  263. static inline void __user *
  264. get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
  265. {
  266. if (ka->sa.sa_flags & SA_ONSTACK) {
  267. if (sas_ss_flags(sp) == 0)
  268. sp = current->sas_ss_sp + current->sas_ss_size;
  269. }
  270. return (void __user *)((sp - (frame_size+UNWINDGUARD)) & -8ul);
  271. }
  272. /* These symbols are defined with the addresses in the vsyscall page.
  273. See vsyscall-trapa.S. */
  274. extern void __kernel_sigreturn(void);
  275. extern void __kernel_rt_sigreturn(void);
  276. static int setup_frame(int sig, struct k_sigaction *ka,
  277. sigset_t *set, struct pt_regs *regs)
  278. {
  279. struct sigframe __user *frame;
  280. int err = 0;
  281. int signal;
  282. frame = get_sigframe(ka, regs->regs[15], sizeof(*frame));
  283. if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
  284. goto give_sigsegv;
  285. signal = current_thread_info()->exec_domain
  286. && current_thread_info()->exec_domain->signal_invmap
  287. && sig < 32
  288. ? current_thread_info()->exec_domain->signal_invmap[sig]
  289. : sig;
  290. err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
  291. if (_NSIG_WORDS > 1)
  292. err |= __copy_to_user(frame->extramask, &set->sig[1],
  293. sizeof(frame->extramask));
  294. /* Set up to return from userspace. If provided, use a stub
  295. already in userspace. */
  296. if (ka->sa.sa_flags & SA_RESTORER) {
  297. regs->pr = (unsigned long) ka->sa.sa_restorer;
  298. #ifdef CONFIG_VSYSCALL
  299. } else if (likely(current->mm->context.vdso)) {
  300. regs->pr = VDSO_SYM(&__kernel_sigreturn);
  301. #endif
  302. } else {
  303. /* Generate return code (system call to sigreturn) */
  304. err |= __put_user(MOVW(7), &frame->retcode[0]);
  305. err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
  306. err |= __put_user(OR_R0_R0, &frame->retcode[2]);
  307. err |= __put_user(OR_R0_R0, &frame->retcode[3]);
  308. err |= __put_user(OR_R0_R0, &frame->retcode[4]);
  309. err |= __put_user(OR_R0_R0, &frame->retcode[5]);
  310. err |= __put_user(OR_R0_R0, &frame->retcode[6]);
  311. err |= __put_user((__NR_sigreturn), &frame->retcode[7]);
  312. regs->pr = (unsigned long) frame->retcode;
  313. flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
  314. }
  315. if (err)
  316. goto give_sigsegv;
  317. /* Set up registers for signal handler */
  318. regs->regs[15] = (unsigned long) frame;
  319. regs->regs[4] = signal; /* Arg for signal handler */
  320. regs->regs[5] = 0;
  321. regs->regs[6] = (unsigned long) &frame->sc;
  322. if (current->personality & FDPIC_FUNCPTRS) {
  323. struct fdpic_func_descriptor __user *funcptr =
  324. (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
  325. __get_user(regs->pc, &funcptr->text);
  326. __get_user(regs->regs[12], &funcptr->GOT);
  327. } else
  328. regs->pc = (unsigned long)ka->sa.sa_handler;
  329. set_fs(USER_DS);
  330. pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
  331. current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
  332. return 0;
  333. give_sigsegv:
  334. force_sigsegv(sig, current);
  335. return -EFAULT;
  336. }
  337. static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
  338. sigset_t *set, struct pt_regs *regs)
  339. {
  340. struct rt_sigframe __user *frame;
  341. int err = 0;
  342. int signal;
  343. frame = get_sigframe(ka, regs->regs[15], sizeof(*frame));
  344. if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
  345. goto give_sigsegv;
  346. signal = current_thread_info()->exec_domain
  347. && current_thread_info()->exec_domain->signal_invmap
  348. && sig < 32
  349. ? current_thread_info()->exec_domain->signal_invmap[sig]
  350. : sig;
  351. err |= copy_siginfo_to_user(&frame->info, info);
  352. /* Create the ucontext. */
  353. err |= __put_user(0, &frame->uc.uc_flags);
  354. err |= __put_user(NULL, &frame->uc.uc_link);
  355. err |= __put_user((void *)current->sas_ss_sp,
  356. &frame->uc.uc_stack.ss_sp);
  357. err |= __put_user(sas_ss_flags(regs->regs[15]),
  358. &frame->uc.uc_stack.ss_flags);
  359. err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size);
  360. err |= setup_sigcontext(&frame->uc.uc_mcontext,
  361. regs, set->sig[0]);
  362. err |= __copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
  363. /* Set up to return from userspace. If provided, use a stub
  364. already in userspace. */
  365. if (ka->sa.sa_flags & SA_RESTORER) {
  366. regs->pr = (unsigned long) ka->sa.sa_restorer;
  367. #ifdef CONFIG_VSYSCALL
  368. } else if (likely(current->mm->context.vdso)) {
  369. regs->pr = VDSO_SYM(&__kernel_rt_sigreturn);
  370. #endif
  371. } else {
  372. /* Generate return code (system call to rt_sigreturn) */
  373. err |= __put_user(MOVW(7), &frame->retcode[0]);
  374. err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
  375. err |= __put_user(OR_R0_R0, &frame->retcode[2]);
  376. err |= __put_user(OR_R0_R0, &frame->retcode[3]);
  377. err |= __put_user(OR_R0_R0, &frame->retcode[4]);
  378. err |= __put_user(OR_R0_R0, &frame->retcode[5]);
  379. err |= __put_user(OR_R0_R0, &frame->retcode[6]);
  380. err |= __put_user((__NR_rt_sigreturn), &frame->retcode[7]);
  381. regs->pr = (unsigned long) frame->retcode;
  382. flush_icache_range(regs->pr, regs->pr + sizeof(frame->retcode));
  383. }
  384. if (err)
  385. goto give_sigsegv;
  386. /* Set up registers for signal handler */
  387. regs->regs[15] = (unsigned long) frame;
  388. regs->regs[4] = signal; /* Arg for signal handler */
  389. regs->regs[5] = (unsigned long) &frame->info;
  390. regs->regs[6] = (unsigned long) &frame->uc;
  391. if (current->personality & FDPIC_FUNCPTRS) {
  392. struct fdpic_func_descriptor __user *funcptr =
  393. (struct fdpic_func_descriptor __user *)ka->sa.sa_handler;
  394. __get_user(regs->pc, &funcptr->text);
  395. __get_user(regs->regs[12], &funcptr->GOT);
  396. } else
  397. regs->pc = (unsigned long)ka->sa.sa_handler;
  398. set_fs(USER_DS);
  399. pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
  400. current->comm, task_pid_nr(current), frame, regs->pc, regs->pr);
  401. return 0;
  402. give_sigsegv:
  403. force_sigsegv(sig, current);
  404. return -EFAULT;
  405. }
  406. static inline void
  407. handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
  408. struct sigaction *sa)
  409. {
  410. /* If we're not from a syscall, bail out */
  411. if (regs->tra < 0)
  412. return;
  413. /* check for system call restart.. */
  414. switch (regs->regs[0]) {
  415. case -ERESTART_RESTARTBLOCK:
  416. case -ERESTARTNOHAND:
  417. no_system_call_restart:
  418. regs->regs[0] = -EINTR;
  419. break;
  420. case -ERESTARTSYS:
  421. if (!(sa->sa_flags & SA_RESTART))
  422. goto no_system_call_restart;
  423. /* fallthrough */
  424. case -ERESTARTNOINTR:
  425. regs->regs[0] = save_r0;
  426. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  427. break;
  428. }
  429. }
  430. /*
  431. * OK, we're invoking a handler
  432. */
  433. static int
  434. handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
  435. sigset_t *oldset, struct pt_regs *regs, unsigned int save_r0)
  436. {
  437. int ret;
  438. /* Set up the stack frame */
  439. if (ka->sa.sa_flags & SA_SIGINFO)
  440. ret = setup_rt_frame(sig, ka, info, oldset, regs);
  441. else
  442. ret = setup_frame(sig, ka, oldset, regs);
  443. if (ret == 0)
  444. block_sigmask(ka, sig);
  445. return ret;
  446. }
  447. /*
  448. * Note that 'init' is a special process: it doesn't get signals it doesn't
  449. * want to handle. Thus you cannot kill init even with a SIGKILL even by
  450. * mistake.
  451. *
  452. * Note that we go through the signals twice: once to check the signals that
  453. * the kernel can handle, and then we build all the user-level signal handling
  454. * stack-frames in one go after that.
  455. */
  456. static void do_signal(struct pt_regs *regs, unsigned int save_r0)
  457. {
  458. siginfo_t info;
  459. int signr;
  460. struct k_sigaction ka;
  461. sigset_t *oldset;
  462. /*
  463. * We want the common case to go fast, which
  464. * is why we may in certain cases get here from
  465. * kernel mode. Just return without doing anything
  466. * if so.
  467. */
  468. if (!user_mode(regs))
  469. return;
  470. if (current_thread_info()->status & TS_RESTORE_SIGMASK)
  471. oldset = &current->saved_sigmask;
  472. else
  473. oldset = &current->blocked;
  474. signr = get_signal_to_deliver(&info, &ka, regs, NULL);
  475. if (signr > 0) {
  476. handle_syscall_restart(save_r0, regs, &ka.sa);
  477. /* Whee! Actually deliver the signal. */
  478. if (handle_signal(signr, &ka, &info, oldset,
  479. regs, save_r0) == 0) {
  480. /*
  481. * A signal was successfully delivered; the saved
  482. * sigmask will have been stored in the signal frame,
  483. * and will be restored by sigreturn, so we can simply
  484. * clear the TS_RESTORE_SIGMASK flag
  485. */
  486. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  487. tracehook_signal_handler(signr, &info, &ka, regs,
  488. test_thread_flag(TIF_SINGLESTEP));
  489. }
  490. return;
  491. }
  492. /* Did we come from a system call? */
  493. if (regs->tra >= 0) {
  494. /* Restart the system call - no handlers present */
  495. if (regs->regs[0] == -ERESTARTNOHAND ||
  496. regs->regs[0] == -ERESTARTSYS ||
  497. regs->regs[0] == -ERESTARTNOINTR) {
  498. regs->regs[0] = save_r0;
  499. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  500. } else if (regs->regs[0] == -ERESTART_RESTARTBLOCK) {
  501. regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
  502. regs->regs[3] = __NR_restart_syscall;
  503. }
  504. }
  505. /*
  506. * If there's no signal to deliver, we just put the saved sigmask
  507. * back.
  508. */
  509. if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
  510. current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
  511. sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
  512. }
  513. }
  514. asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
  515. unsigned long thread_info_flags)
  516. {
  517. /* deal with pending signal delivery */
  518. if (thread_info_flags & _TIF_SIGPENDING)
  519. do_signal(regs, save_r0);
  520. if (thread_info_flags & _TIF_NOTIFY_RESUME) {
  521. clear_thread_flag(TIF_NOTIFY_RESUME);
  522. tracehook_notify_resume(regs);
  523. if (current->replacement_session_keyring)
  524. key_replace_session_keyring();
  525. }
  526. }