77 lines
2.5 KiB
Diff
77 lines
2.5 KiB
Diff
|
From 0c1b5ce8de67c36bbf67db38240a91f358133bdd Mon Sep 17 00:00:00 2001
|
||
|
From: Jiri Slaby <jirislaby@gmail.com>
|
||
|
Date: Fri, 28 Aug 2009 14:05:12 +0200
|
||
|
Subject: [PATCH] core: add task_struct to update_rlimit_cpu
|
||
|
References: FATE#305733
|
||
|
Patch-mainline: no (later)
|
||
|
|
||
|
Add task_struct as a parameter to update_rlimit_cpu to be able to set
|
||
|
rlimit_cpu of different task than current.
|
||
|
|
||
|
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
|
||
|
Acked-by: James Morris <jmorris@namei.org>
|
||
|
---
|
||
|
include/linux/posix-timers.h | 2 +-
|
||
|
kernel/posix-cpu-timers.c | 10 +++++-----
|
||
|
kernel/sys.c | 2 +-
|
||
|
security/selinux/hooks.c | 3 ++-
|
||
|
4 files changed, 9 insertions(+), 8 deletions(-)
|
||
|
|
||
|
--- a/include/linux/posix-timers.h
|
||
|
+++ b/include/linux/posix-timers.h
|
||
|
@@ -117,6 +117,6 @@ void set_process_cpu_timer(struct task_s
|
||
|
|
||
|
long clock_nanosleep_restart(struct restart_block *restart_block);
|
||
|
|
||
|
-void update_rlimit_cpu(unsigned long rlim_new);
|
||
|
+void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
|
||
|
|
||
|
#endif
|
||
|
--- a/kernel/posix-cpu-timers.c
|
||
|
+++ b/kernel/posix-cpu-timers.c
|
||
|
@@ -13,16 +13,16 @@
|
||
|
/*
|
||
|
* Called after updating RLIMIT_CPU to set timer expiration if necessary.
|
||
|
*/
|
||
|
-void update_rlimit_cpu(unsigned long rlim_new)
|
||
|
+void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
|
||
|
{
|
||
|
cputime_t cputime = secs_to_cputime(rlim_new);
|
||
|
- struct signal_struct *const sig = current->signal;
|
||
|
+ struct signal_struct *const sig = task->signal;
|
||
|
|
||
|
if (cputime_eq(sig->it[CPUCLOCK_PROF].expires, cputime_zero) ||
|
||
|
cputime_gt(sig->it[CPUCLOCK_PROF].expires, cputime)) {
|
||
|
- spin_lock_irq(¤t->sighand->siglock);
|
||
|
- set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
|
||
|
- spin_unlock_irq(¤t->sighand->siglock);
|
||
|
+ spin_lock_irq(&task->sighand->siglock);
|
||
|
+ set_process_cpu_timer(task, CPUCLOCK_PROF, &cputime, NULL);
|
||
|
+ spin_unlock_irq(&task->sighand->siglock);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
--- a/kernel/sys.c
|
||
|
+++ b/kernel/sys.c
|
||
|
@@ -1350,7 +1350,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int,
|
||
|
if (new_rlim.rlim_cur == RLIM_INFINITY)
|
||
|
goto out;
|
||
|
|
||
|
- update_rlimit_cpu(new_rlim.rlim_cur);
|
||
|
+ update_rlimit_cpu(current, new_rlim.rlim_cur);
|
||
|
out:
|
||
|
return 0;
|
||
|
}
|
||
|
--- a/security/selinux/hooks.c
|
||
|
+++ b/security/selinux/hooks.c
|
||
|
@@ -2360,7 +2360,8 @@ static void selinux_bprm_committing_cred
|
||
|
initrlim = init_task.signal->rlim + i;
|
||
|
rlim->rlim_cur = min(rlim->rlim_max, initrlim->rlim_cur);
|
||
|
}
|
||
|
- update_rlimit_cpu(current->signal->rlim[RLIMIT_CPU].rlim_cur);
|
||
|
+ update_rlimit_cpu(current,
|
||
|
+ current->signal->rlim[RLIMIT_CPU].rlim_cur);
|
||
|
}
|
||
|
}
|
||
|
|