aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/fork.c10
-rw-r--r--kernel/perf_event.c2
-rw-r--r--kernel/posix-cpu-timers.c10
-rw-r--r--kernel/sched.c4
-rw-r--r--kernel/sched_rt.c5
-rw-r--r--kernel/signal.c2
-rw-r--r--kernel/sys.c3
7 files changed, 20 insertions, 16 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index bab7b254ad39..b0ec34abc0bb 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -828,6 +828,8 @@ void __cleanup_sighand(struct sighand_struct *sighand)
828 */ 828 */
829static void posix_cpu_timers_init_group(struct signal_struct *sig) 829static void posix_cpu_timers_init_group(struct signal_struct *sig)
830{ 830{
831 unsigned long cpu_limit;
832
831 /* Thread group counters. */ 833 /* Thread group counters. */
832 thread_group_cputime_init(sig); 834 thread_group_cputime_init(sig);
833 835
@@ -842,9 +844,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
842 sig->cputime_expires.virt_exp = cputime_zero; 844 sig->cputime_expires.virt_exp = cputime_zero;
843 sig->cputime_expires.sched_exp = 0; 845 sig->cputime_expires.sched_exp = 0;
844 846
845 if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) { 847 cpu_limit = ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
846 sig->cputime_expires.prof_exp = 848 if (cpu_limit != RLIM_INFINITY) {
847 secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur); 849 sig->cputime_expires.prof_exp = secs_to_cputime(cpu_limit);
848 sig->cputimer.running = 1; 850 sig->cputimer.running = 1;
849 } 851 }
850 852
@@ -1037,7 +1039,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1037#endif 1039#endif
1038 retval = -EAGAIN; 1040 retval = -EAGAIN;
1039 if (atomic_read(&p->real_cred->user->processes) >= 1041 if (atomic_read(&p->real_cred->user->processes) >=
1040 p->signal->rlim[RLIMIT_NPROC].rlim_cur) { 1042 task_rlimit(p, RLIMIT_NPROC)) {
1041 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && 1043 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
1042 p->real_cred->user != INIT_USER) 1044 p->real_cred->user != INIT_USER)
1043 goto bad_fork_free; 1045 goto bad_fork_free;
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index a661e7991865..8e352c756ba7 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2610,7 +2610,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
2610 if (user_locked > user_lock_limit) 2610 if (user_locked > user_lock_limit)
2611 extra = user_locked - user_lock_limit; 2611 extra = user_locked - user_lock_limit;
2612 2612
2613 lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; 2613 lock_limit = rlimit(RLIMIT_MEMLOCK);
2614 lock_limit >>= PAGE_SHIFT; 2614 lock_limit >>= PAGE_SHIFT;
2615 locked = vma->vm_mm->locked_vm + extra; 2615 locked = vma->vm_mm->locked_vm + extra;
2616 2616
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index dbb16bf15c45..1a22dfd42df9 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1031,9 +1031,10 @@ static void check_thread_timers(struct task_struct *tsk,
1031 /* 1031 /*
1032 * Check for the special case thread timers. 1032 * Check for the special case thread timers.
1033 */ 1033 */
1034 soft = sig->rlim[RLIMIT_RTTIME].rlim_cur; 1034 soft = ACCESS_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_cur);
1035 if (soft != RLIM_INFINITY) { 1035 if (soft != RLIM_INFINITY) {
1036 unsigned long hard = sig->rlim[RLIMIT_RTTIME].rlim_max; 1036 unsigned long hard =
1037 ACCESS_ONCE(sig->rlim[RLIMIT_RTTIME].rlim_max);
1037 1038
1038 if (hard != RLIM_INFINITY && 1039 if (hard != RLIM_INFINITY &&
1039 tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) { 1040 tsk->rt.timeout > DIV_ROUND_UP(hard, USEC_PER_SEC/HZ)) {
@@ -1194,10 +1195,11 @@ static void check_process_timers(struct task_struct *tsk,
1194 SIGPROF); 1195 SIGPROF);
1195 check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime, 1196 check_cpu_itimer(tsk, &sig->it[CPUCLOCK_VIRT], &virt_expires, utime,
1196 SIGVTALRM); 1197 SIGVTALRM);
1197 soft = sig->rlim[RLIMIT_CPU].rlim_cur; 1198 soft = ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
1198 if (soft != RLIM_INFINITY) { 1199 if (soft != RLIM_INFINITY) {
1199 unsigned long psecs = cputime_to_secs(ptime); 1200 unsigned long psecs = cputime_to_secs(ptime);
1200 unsigned long hard = sig->rlim[RLIMIT_CPU].rlim_max; 1201 unsigned long hard =
1202 ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_max);
1201 cputime_t x; 1203 cputime_t x;
1202 if (psecs >= hard) { 1204 if (psecs >= hard) {
1203 /* 1205 /*
diff --git a/kernel/sched.c b/kernel/sched.c
index abb36b16b93b..b47ceeec1a91 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4353,7 +4353,7 @@ int can_nice(const struct task_struct *p, const int nice)
4353 /* convert nice value [19,-20] to rlimit style value [1,40] */ 4353 /* convert nice value [19,-20] to rlimit style value [1,40] */
4354 int nice_rlim = 20 - nice; 4354 int nice_rlim = 20 - nice;
4355 4355
4356 return (nice_rlim <= p->signal->rlim[RLIMIT_NICE].rlim_cur || 4356 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
4357 capable(CAP_SYS_NICE)); 4357 capable(CAP_SYS_NICE));
4358} 4358}
4359 4359
@@ -4530,7 +4530,7 @@ recheck:
4530 4530
4531 if (!lock_task_sighand(p, &flags)) 4531 if (!lock_task_sighand(p, &flags))
4532 return -ESRCH; 4532 return -ESRCH;
4533 rlim_rtprio = p->signal->rlim[RLIMIT_RTPRIO].rlim_cur; 4533 rlim_rtprio = task_rlimit(p, RLIMIT_RTPRIO);
4534 unlock_task_sighand(p, &flags); 4534 unlock_task_sighand(p, &flags);
4535 4535
4536 /* can't set/change the rt policy */ 4536 /* can't set/change the rt policy */
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index bf3e38fdbe6d..5a6ed1f0990a 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1662,8 +1662,9 @@ static void watchdog(struct rq *rq, struct task_struct *p)
1662 if (!p->signal) 1662 if (!p->signal)
1663 return; 1663 return;
1664 1664
1665 soft = p->signal->rlim[RLIMIT_RTTIME].rlim_cur; 1665 /* max may change after cur was read, this will be fixed next tick */
1666 hard = p->signal->rlim[RLIMIT_RTTIME].rlim_max; 1666 soft = task_rlimit(p, RLIMIT_RTTIME);
1667 hard = task_rlimit_max(p, RLIMIT_RTTIME);
1667 1668
1668 if (soft != RLIM_INFINITY) { 1669 if (soft != RLIM_INFINITY) {
1669 unsigned long next; 1670 unsigned long next;
diff --git a/kernel/signal.c b/kernel/signal.c
index 5bb9baffa4f1..dbd7fe073c55 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -245,7 +245,7 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
245 245
246 if (override_rlimit || 246 if (override_rlimit ||
247 atomic_read(&user->sigpending) <= 247 atomic_read(&user->sigpending) <=
248 t->signal->rlim[RLIMIT_SIGPENDING].rlim_cur) { 248 task_rlimit(t, RLIMIT_SIGPENDING)) {
249 q = kmem_cache_alloc(sigqueue_cachep, flags); 249 q = kmem_cache_alloc(sigqueue_cachep, flags);
250 } else { 250 } else {
251 print_dropped_signal(sig); 251 print_dropped_signal(sig);
diff --git a/kernel/sys.c b/kernel/sys.c
index 877fe4f8e05e..9814e43fb23b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -571,8 +571,7 @@ static int set_user(struct cred *new)
571 if (!new_user) 571 if (!new_user)
572 return -EAGAIN; 572 return -EAGAIN;
573 573
574 if (atomic_read(&new_user->processes) >= 574 if (atomic_read(&new_user->processes) >= rlimit(RLIMIT_NPROC) &&
575 current->signal->rlim[RLIMIT_NPROC].rlim_cur &&
576 new_user != INIT_USER) { 575 new_user != INIT_USER) {
577 free_uid(new_user); 576 free_uid(new_user);
578 return -EAGAIN; 577 return -EAGAIN;