diff options
author | Jiri Slaby <jslaby@suse.cz> | 2010-03-05 16:42:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:33 -0500 |
commit | 78d7d407b62a021e6d2e8dc24c0b90e390ab58a1 (patch) | |
tree | 8c1074b84db4b977bad6802a3701e0113c0a7739 /kernel/fork.c | |
parent | d4bb527438b4181cd3c564ae04dd344c381283a1 (diff) |
kernel core: use helpers for rlimits
Make sure compiler won't do weird things with limits. E.g. fetching them
twice may return 2 different values after writable limits are implemented.
I.e. either use rlimit helpers added in commit 3e10e716abf3 ("resource:
add helpers for fetching rlimits") or ACCESS_ONCE if not applicable.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r-- | kernel/fork.c | 10 |
1 files changed, 6 insertions, 4 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 | */ |
829 | static void posix_cpu_timers_init_group(struct signal_struct *sig) | 829 | static 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; |