signal.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SCHED_SIGNAL_H
  3. #define _LINUX_SCHED_SIGNAL_H
  4. #include <linux/rculist.h>
  5. #include <linux/signal.h>
  6. #include <linux/sched.h>
  7. #include <linux/sched/jobctl.h>
  8. #include <linux/sched/task.h>
  9. #include <linux/cred.h>
  10. /*
  11. * Types defining task->signal and task->sighand and APIs using them:
  12. */
  13. struct sighand_struct {
  14. atomic_t count;
  15. struct k_sigaction action[_NSIG];
  16. spinlock_t siglock;
  17. wait_queue_head_t signalfd_wqh;
  18. };
  19. /*
  20. * Per-process accounting stats:
  21. */
  22. struct pacct_struct {
  23. int ac_flag;
  24. long ac_exitcode;
  25. unsigned long ac_mem;
  26. u64 ac_utime, ac_stime;
  27. unsigned long ac_minflt, ac_majflt;
  28. };
  29. struct cpu_itimer {
  30. u64 expires;
  31. u64 incr;
  32. };
  33. /*
  34. * This is the atomic variant of task_cputime, which can be used for
  35. * storing and updating task_cputime statistics without locking.
  36. */
  37. struct task_cputime_atomic {
  38. atomic64_t utime;
  39. atomic64_t stime;
  40. atomic64_t sum_exec_runtime;
  41. };
  42. #define INIT_CPUTIME_ATOMIC \
  43. (struct task_cputime_atomic) { \
  44. .utime = ATOMIC64_INIT(0), \
  45. .stime = ATOMIC64_INIT(0), \
  46. .sum_exec_runtime = ATOMIC64_INIT(0), \
  47. }
  48. /**
  49. * struct thread_group_cputimer - thread group interval timer counts
  50. * @cputime_atomic: atomic thread group interval timers.
  51. * @running: true when there are timers running and
  52. * @cputime_atomic receives updates.
  53. * @checking_timer: true when a thread in the group is in the
  54. * process of checking for thread group timers.
  55. *
  56. * This structure contains the version of task_cputime, above, that is
  57. * used for thread group CPU timer calculations.
  58. */
  59. struct thread_group_cputimer {
  60. struct task_cputime_atomic cputime_atomic;
  61. bool running;
  62. bool checking_timer;
  63. };
  64. /*
  65. * NOTE! "signal_struct" does not have its own
  66. * locking, because a shared signal_struct always
  67. * implies a shared sighand_struct, so locking
  68. * sighand_struct is always a proper superset of
  69. * the locking of signal_struct.
  70. */
  71. struct signal_struct {
  72. atomic_t sigcnt;
  73. atomic_t live;
  74. int nr_threads;
  75. struct list_head thread_head;
  76. wait_queue_head_t wait_chldexit; /* for wait4() */
  77. /* current thread group signal load-balancing target: */
  78. struct task_struct *curr_target;
  79. /* shared signal handling: */
  80. struct sigpending shared_pending;
  81. /* thread group exit support */
  82. int group_exit_code;
  83. /* overloaded:
  84. * - notify group_exit_task when ->count is equal to notify_count
  85. * - everyone except group_exit_task is stopped during signal delivery
  86. * of fatal signals, group_exit_task processes the signal.
  87. */
  88. int notify_count;
  89. struct task_struct *group_exit_task;
  90. /* thread group stop support, overloads group_exit_code too */
  91. int group_stop_count;
  92. unsigned int flags; /* see SIGNAL_* flags below */
  93. /*
  94. * PR_SET_CHILD_SUBREAPER marks a process, like a service
  95. * manager, to re-parent orphan (double-forking) child processes
  96. * to this process instead of 'init'. The service manager is
  97. * able to receive SIGCHLD signals and is able to investigate
  98. * the process until it calls wait(). All children of this
  99. * process will inherit a flag if they should look for a
  100. * child_subreaper process at exit.
  101. */
  102. unsigned int is_child_subreaper:1;
  103. unsigned int has_child_subreaper:1;
  104. #ifdef CONFIG_POSIX_TIMERS
  105. /* POSIX.1b Interval Timers */
  106. int posix_timer_id;
  107. struct list_head posix_timers;
  108. /* ITIMER_REAL timer for the process */
  109. struct hrtimer real_timer;
  110. ktime_t it_real_incr;
  111. /*
  112. * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use
  113. * CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these
  114. * values are defined to 0 and 1 respectively
  115. */
  116. struct cpu_itimer it[2];
  117. /*
  118. * Thread group totals for process CPU timers.
  119. * See thread_group_cputimer(), et al, for details.
  120. */
  121. struct thread_group_cputimer cputimer;
  122. /* Earliest-expiration cache. */
  123. struct task_cputime cputime_expires;
  124. struct list_head cpu_timers[3];
  125. #endif
  126. struct pid *leader_pid;
  127. #ifdef CONFIG_NO_HZ_FULL
  128. atomic_t tick_dep_mask;
  129. #endif
  130. struct pid *tty_old_pgrp;
  131. /* boolean value for session group leader */
  132. int leader;
  133. struct tty_struct *tty; /* NULL if no tty */
  134. #ifdef CONFIG_SCHED_AUTOGROUP
  135. struct autogroup *autogroup;
  136. #endif
  137. /*
  138. * Cumulative resource counters for dead threads in the group,
  139. * and for reaped dead child processes forked by this group.
  140. * Live threads maintain their own counters and add to these
  141. * in __exit_signal, except for the group leader.
  142. */
  143. seqlock_t stats_lock;
  144. u64 utime, stime, cutime, cstime;
  145. u64 gtime;
  146. u64 cgtime;
  147. struct prev_cputime prev_cputime;
  148. unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
  149. unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
  150. unsigned long inblock, oublock, cinblock, coublock;
  151. unsigned long maxrss, cmaxrss;
  152. struct task_io_accounting ioac;
  153. /*
  154. * Cumulative ns of schedule CPU time fo dead threads in the
  155. * group, not including a zombie group leader, (This only differs
  156. * from jiffies_to_ns(utime + stime) if sched_clock uses something
  157. * other than jiffies.)
  158. */
  159. unsigned long long sum_sched_runtime;
  160. /*
  161. * We don't bother to synchronize most readers of this at all,
  162. * because there is no reader checking a limit that actually needs
  163. * to get both rlim_cur and rlim_max atomically, and either one
  164. * alone is a single word that can safely be read normally.
  165. * getrlimit/setrlimit use task_lock(current->group_leader) to
  166. * protect this instead of the siglock, because they really
  167. * have no need to disable irqs.
  168. */
  169. struct rlimit rlim[RLIM_NLIMITS];
  170. #ifdef CONFIG_BSD_PROCESS_ACCT
  171. struct pacct_struct pacct; /* per-process accounting information */
  172. #endif
  173. #ifdef CONFIG_TASKSTATS
  174. struct taskstats *stats;
  175. #endif
  176. #ifdef CONFIG_AUDIT
  177. unsigned audit_tty;
  178. struct tty_audit_buf *tty_audit_buf;
  179. #endif
  180. /*
  181. * Thread is the potential origin of an oom condition; kill first on
  182. * oom
  183. */
  184. bool oom_flag_origin;
  185. short oom_score_adj; /* OOM kill score adjustment */
  186. short oom_score_adj_min; /* OOM kill score adjustment min value.
  187. * Only settable by CAP_SYS_RESOURCE. */
  188. struct mm_struct *oom_mm; /* recorded mm when the thread group got
  189. * killed by the oom killer */
  190. struct mutex cred_guard_mutex; /* guard against foreign influences on
  191. * credential calculations
  192. * (notably. ptrace) */
  193. } __randomize_layout;
  194. /*
  195. * Bits in flags field of signal_struct.
  196. */
  197. #define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */
  198. #define SIGNAL_STOP_CONTINUED 0x00000002 /* SIGCONT since WCONTINUED reap */
  199. #define SIGNAL_GROUP_EXIT 0x00000004 /* group exit in progress */
  200. #define SIGNAL_GROUP_COREDUMP 0x00000008 /* coredump in progress */
  201. /*
  202. * Pending notifications to parent.
  203. */
  204. #define SIGNAL_CLD_STOPPED 0x00000010
  205. #define SIGNAL_CLD_CONTINUED 0x00000020
  206. #define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
  207. #define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
  208. #define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
  209. SIGNAL_STOP_CONTINUED)
  210. static inline void signal_set_stop_flags(struct signal_struct *sig,
  211. unsigned int flags)
  212. {
  213. WARN_ON(sig->flags & (SIGNAL_GROUP_EXIT|SIGNAL_GROUP_COREDUMP));
  214. sig->flags = (sig->flags & ~SIGNAL_STOP_MASK) | flags;
  215. }
  216. /* If true, all threads except ->group_exit_task have pending SIGKILL */
  217. static inline int signal_group_exit(const struct signal_struct *sig)
  218. {
  219. return (sig->flags & SIGNAL_GROUP_EXIT) ||
  220. (sig->group_exit_task != NULL);
  221. }
  222. extern void flush_signals(struct task_struct *);
  223. extern void ignore_signals(struct task_struct *);
  224. extern void flush_signal_handlers(struct task_struct *, int force_default);
  225. extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
  226. static inline int kernel_dequeue_signal(siginfo_t *info)
  227. {
  228. struct task_struct *tsk = current;
  229. siginfo_t __info;
  230. int ret;
  231. spin_lock_irq(&tsk->sighand->siglock);
  232. ret = dequeue_signal(tsk, &tsk->blocked, info ?: &__info);
  233. spin_unlock_irq(&tsk->sighand->siglock);
  234. return ret;
  235. }
  236. static inline void kernel_signal_stop(void)
  237. {
  238. spin_lock_irq(&current->sighand->siglock);
  239. if (current->jobctl & JOBCTL_STOP_DEQUEUED)
  240. __set_current_state(TASK_STOPPED);
  241. spin_unlock_irq(&current->sighand->siglock);
  242. schedule();
  243. }
  244. #ifdef __ARCH_SI_TRAPNO
  245. # define ___ARCH_SI_TRAPNO(_a1) , _a1
  246. #else
  247. # define ___ARCH_SI_TRAPNO(_a1)
  248. #endif
  249. #ifdef __ia64__
  250. # define ___ARCH_SI_IA64(_a1, _a2, _a3) , _a1, _a2, _a3
  251. #else
  252. # define ___ARCH_SI_IA64(_a1, _a2, _a3)
  253. #endif
  254. int force_sig_fault(int sig, int code, void __user *addr
  255. ___ARCH_SI_TRAPNO(int trapno)
  256. ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
  257. , struct task_struct *t);
  258. int send_sig_fault(int sig, int code, void __user *addr
  259. ___ARCH_SI_TRAPNO(int trapno)
  260. ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
  261. , struct task_struct *t);
  262. extern int send_sig_info(int, struct siginfo *, struct task_struct *);
  263. extern int force_sigsegv(int, struct task_struct *);
  264. extern int force_sig_info(int, struct siginfo *, struct task_struct *);
  265. extern int __kill_pgrp_info(int sig, struct siginfo *info, struct pid *pgrp);
  266. extern int kill_pid_info(int sig, struct siginfo *info, struct pid *pid);
  267. extern int kill_pid_info_as_cred(int, struct siginfo *, struct pid *,
  268. const struct cred *, u32);
  269. extern int kill_pgrp(struct pid *pid, int sig, int priv);
  270. extern int kill_pid(struct pid *pid, int sig, int priv);
  271. extern __must_check bool do_notify_parent(struct task_struct *, int);
  272. extern void __wake_up_parent(struct task_struct *p, struct task_struct *parent);
  273. extern void force_sig(int, struct task_struct *);
  274. extern int send_sig(int, struct task_struct *, int);
  275. extern int zap_other_threads(struct task_struct *p);
  276. extern struct sigqueue *sigqueue_alloc(void);
  277. extern void sigqueue_free(struct sigqueue *);
  278. extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
  279. extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
  280. static inline int restart_syscall(void)
  281. {
  282. set_tsk_thread_flag(current, TIF_SIGPENDING);
  283. return -ERESTARTNOINTR;
  284. }
  285. static inline int signal_pending(struct task_struct *p)
  286. {
  287. return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
  288. }
  289. static inline int __fatal_signal_pending(struct task_struct *p)
  290. {
  291. return unlikely(sigismember(&p->pending.signal, SIGKILL));
  292. }
  293. static inline int fatal_signal_pending(struct task_struct *p)
  294. {
  295. return signal_pending(p) && __fatal_signal_pending(p);
  296. }
  297. static inline int signal_pending_state(long state, struct task_struct *p)
  298. {
  299. if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
  300. return 0;
  301. if (!signal_pending(p))
  302. return 0;
  303. return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
  304. }
  305. /*
  306. * Reevaluate whether the task has signals pending delivery.
  307. * Wake the task if so.
  308. * This is required every time the blocked sigset_t changes.
  309. * callers must hold sighand->siglock.
  310. */
  311. extern void recalc_sigpending_and_wake(struct task_struct *t);
  312. extern void recalc_sigpending(void);
  313. extern void signal_wake_up_state(struct task_struct *t, unsigned int state);
  314. static inline void signal_wake_up(struct task_struct *t, bool resume)
  315. {
  316. signal_wake_up_state(t, resume ? TASK_WAKEKILL : 0);
  317. }
  318. static inline void ptrace_signal_wake_up(struct task_struct *t, bool resume)
  319. {
  320. signal_wake_up_state(t, resume ? __TASK_TRACED : 0);
  321. }
  322. #ifdef TIF_RESTORE_SIGMASK
  323. /*
  324. * Legacy restore_sigmask accessors. These are inefficient on
  325. * SMP architectures because they require atomic operations.
  326. */
  327. /**
  328. * set_restore_sigmask() - make sure saved_sigmask processing gets done
  329. *
  330. * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code
  331. * will run before returning to user mode, to process the flag. For
  332. * all callers, TIF_SIGPENDING is already set or it's no harm to set
  333. * it. TIF_RESTORE_SIGMASK need not be in the set of bits that the
  334. * arch code will notice on return to user mode, in case those bits
  335. * are scarce. We set TIF_SIGPENDING here to ensure that the arch
  336. * signal code always gets run when TIF_RESTORE_SIGMASK is set.
  337. */
  338. static inline void set_restore_sigmask(void)
  339. {
  340. set_thread_flag(TIF_RESTORE_SIGMASK);
  341. WARN_ON(!test_thread_flag(TIF_SIGPENDING));
  342. }
  343. static inline void clear_restore_sigmask(void)
  344. {
  345. clear_thread_flag(TIF_RESTORE_SIGMASK);
  346. }
  347. static inline bool test_restore_sigmask(void)
  348. {
  349. return test_thread_flag(TIF_RESTORE_SIGMASK);
  350. }
  351. static inline bool test_and_clear_restore_sigmask(void)
  352. {
  353. return test_and_clear_thread_flag(TIF_RESTORE_SIGMASK);
  354. }
  355. #else /* TIF_RESTORE_SIGMASK */
  356. /* Higher-quality implementation, used if TIF_RESTORE_SIGMASK doesn't exist. */
  357. static inline void set_restore_sigmask(void)
  358. {
  359. current->restore_sigmask = true;
  360. WARN_ON(!test_thread_flag(TIF_SIGPENDING));
  361. }
  362. static inline void clear_restore_sigmask(void)
  363. {
  364. current->restore_sigmask = false;
  365. }
  366. static inline bool test_restore_sigmask(void)
  367. {
  368. return current->restore_sigmask;
  369. }
  370. static inline bool test_and_clear_restore_sigmask(void)
  371. {
  372. if (!current->restore_sigmask)
  373. return false;
  374. current->restore_sigmask = false;
  375. return true;
  376. }
  377. #endif
  378. static inline void restore_saved_sigmask(void)
  379. {
  380. if (test_and_clear_restore_sigmask())
  381. __set_current_blocked(&current->saved_sigmask);
  382. }
  383. static inline sigset_t *sigmask_to_save(void)
  384. {
  385. sigset_t *res = &current->blocked;
  386. if (unlikely(test_restore_sigmask()))
  387. res = &current->saved_sigmask;
  388. return res;
  389. }
  390. static inline int kill_cad_pid(int sig, int priv)
  391. {
  392. return kill_pid(cad_pid, sig, priv);
  393. }
  394. /* These can be the second arg to send_sig_info/send_group_sig_info. */
  395. #define SEND_SIG_NOINFO ((struct siginfo *) 0)
  396. #define SEND_SIG_PRIV ((struct siginfo *) 1)
  397. #define SEND_SIG_FORCED ((struct siginfo *) 2)
  398. /*
  399. * True if we are on the alternate signal stack.
  400. */
  401. static inline int on_sig_stack(unsigned long sp)
  402. {
  403. /*
  404. * If the signal stack is SS_AUTODISARM then, by construction, we
  405. * can't be on the signal stack unless user code deliberately set
  406. * SS_AUTODISARM when we were already on it.
  407. *
  408. * This improves reliability: if user state gets corrupted such that
  409. * the stack pointer points very close to the end of the signal stack,
  410. * then this check will enable the signal to be handled anyway.
  411. */
  412. if (current->sas_ss_flags & SS_AUTODISARM)
  413. return 0;
  414. #ifdef CONFIG_STACK_GROWSUP
  415. return sp >= current->sas_ss_sp &&
  416. sp - current->sas_ss_sp < current->sas_ss_size;
  417. #else
  418. return sp > current->sas_ss_sp &&
  419. sp - current->sas_ss_sp <= current->sas_ss_size;
  420. #endif
  421. }
  422. static inline int sas_ss_flags(unsigned long sp)
  423. {
  424. if (!current->sas_ss_size)
  425. return SS_DISABLE;
  426. return on_sig_stack(sp) ? SS_ONSTACK : 0;
  427. }
  428. static inline void sas_ss_reset(struct task_struct *p)
  429. {
  430. p->sas_ss_sp = 0;
  431. p->sas_ss_size = 0;
  432. p->sas_ss_flags = SS_DISABLE;
  433. }
  434. static inline unsigned long sigsp(unsigned long sp, struct ksignal *ksig)
  435. {
  436. if (unlikely((ksig->ka.sa.sa_flags & SA_ONSTACK)) && ! sas_ss_flags(sp))
  437. #ifdef CONFIG_STACK_GROWSUP
  438. return current->sas_ss_sp;
  439. #else
  440. return current->sas_ss_sp + current->sas_ss_size;
  441. #endif
  442. return sp;
  443. }
  444. extern void __cleanup_sighand(struct sighand_struct *);
  445. extern void flush_itimer_signals(void);
  446. #define tasklist_empty() \
  447. list_empty(&init_task.tasks)
  448. #define next_task(p) \
  449. list_entry_rcu((p)->tasks.next, struct task_struct, tasks)
  450. #define for_each_process(p) \
  451. for (p = &init_task ; (p = next_task(p)) != &init_task ; )
  452. extern bool current_is_single_threaded(void);
  453. /*
  454. * Careful: do_each_thread/while_each_thread is a double loop so
  455. * 'break' will not work as expected - use goto instead.
  456. */
  457. #define do_each_thread(g, t) \
  458. for (g = t = &init_task ; (g = t = next_task(g)) != &init_task ; ) do
  459. #define while_each_thread(g, t) \
  460. while ((t = next_thread(t)) != g)
  461. #define __for_each_thread(signal, t) \
  462. list_for_each_entry_rcu(t, &(signal)->thread_head, thread_node)
  463. #define for_each_thread(p, t) \
  464. __for_each_thread((p)->signal, t)
  465. /* Careful: this is a double loop, 'break' won't work as expected. */
  466. #define for_each_process_thread(p, t) \
  467. for_each_process(p) for_each_thread(p, t)
  468. typedef int (*proc_visitor)(struct task_struct *p, void *data);
  469. void walk_process_tree(struct task_struct *top, proc_visitor, void *);
  470. static inline int get_nr_threads(struct task_struct *tsk)
  471. {
  472. return tsk->signal->nr_threads;
  473. }
  474. static inline bool thread_group_leader(struct task_struct *p)
  475. {
  476. return p->exit_signal >= 0;
  477. }
  478. /* Do to the insanities of de_thread it is possible for a process
  479. * to have the pid of the thread group leader without actually being
  480. * the thread group leader. For iteration through the pids in proc
  481. * all we care about is that we have a task with the appropriate
  482. * pid, we don't actually care if we have the right task.
  483. */
  484. static inline bool has_group_leader_pid(struct task_struct *p)
  485. {
  486. return task_pid(p) == p->signal->leader_pid;
  487. }
  488. static inline
  489. bool same_thread_group(struct task_struct *p1, struct task_struct *p2)
  490. {
  491. return p1->signal == p2->signal;
  492. }
  493. static inline struct task_struct *next_thread(const struct task_struct *p)
  494. {
  495. return list_entry_rcu(p->thread_group.next,
  496. struct task_struct, thread_group);
  497. }
  498. static inline int thread_group_empty(struct task_struct *p)
  499. {
  500. return list_empty(&p->thread_group);
  501. }
  502. #define delay_group_leader(p) \
  503. (thread_group_leader(p) && !thread_group_empty(p))
  504. extern struct sighand_struct *__lock_task_sighand(struct task_struct *tsk,
  505. unsigned long *flags);
  506. static inline struct sighand_struct *lock_task_sighand(struct task_struct *tsk,
  507. unsigned long *flags)
  508. {
  509. struct sighand_struct *ret;
  510. ret = __lock_task_sighand(tsk, flags);
  511. (void)__cond_lock(&tsk->sighand->siglock, ret);
  512. return ret;
  513. }
  514. static inline void unlock_task_sighand(struct task_struct *tsk,
  515. unsigned long *flags)
  516. {
  517. spin_unlock_irqrestore(&tsk->sighand->siglock, *flags);
  518. }
  519. static inline unsigned long task_rlimit(const struct task_struct *tsk,
  520. unsigned int limit)
  521. {
  522. return READ_ONCE(tsk->signal->rlim[limit].rlim_cur);
  523. }
  524. static inline unsigned long task_rlimit_max(const struct task_struct *tsk,
  525. unsigned int limit)
  526. {
  527. return READ_ONCE(tsk->signal->rlim[limit].rlim_max);
  528. }
  529. static inline unsigned long rlimit(unsigned int limit)
  530. {
  531. return task_rlimit(current, limit);
  532. }
  533. static inline unsigned long rlimit_max(unsigned int limit)
  534. {
  535. return task_rlimit_max(current, limit);
  536. }
  537. #endif /* _LINUX_SCHED_SIGNAL_H */