mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-20 13:41:30 +00:00
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 3e10e716ab
("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>
This commit is contained in:
parent
d4bb527438
commit
78d7d407b6
7 changed files with 20 additions and 16 deletions
|
@ -828,6 +828,8 @@ void __cleanup_sighand(struct sighand_struct *sighand)
|
|||
*/
|
||||
static void posix_cpu_timers_init_group(struct signal_struct *sig)
|
||||
{
|
||||
unsigned long cpu_limit;
|
||||
|
||||
/* Thread group counters. */
|
||||
thread_group_cputime_init(sig);
|
||||
|
||||
|
@ -842,9 +844,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
|
|||
sig->cputime_expires.virt_exp = cputime_zero;
|
||||
sig->cputime_expires.sched_exp = 0;
|
||||
|
||||
if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
|
||||
sig->cputime_expires.prof_exp =
|
||||
secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
|
||||
cpu_limit = ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
|
||||
if (cpu_limit != RLIM_INFINITY) {
|
||||
sig->cputime_expires.prof_exp = secs_to_cputime(cpu_limit);
|
||||
sig->cputimer.running = 1;
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1039,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
|
|||
#endif
|
||||
retval = -EAGAIN;
|
||||
if (atomic_read(&p->real_cred->user->processes) >=
|
||||
p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
|
||||
task_rlimit(p, RLIMIT_NPROC)) {
|
||||
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
|
||||
p->real_cred->user != INIT_USER)
|
||||
goto bad_fork_free;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue