mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
[PATCH] sys_setrlimit() cleanup
- Whitespace cleanups - Make that expression comprehensible. There's a potential logic change here: we do the "is it_prof_expires equal to zero" test after converting it to seconds, rather than doing the comparison between raw cputime_t's. But given that it's in units of seconds anyway, that shouldn't change anything. Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Ulrich Weigand <uweigand@de.ibm.com> Cc: Cliff Wickman <cpw@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
de62a97ef5
commit
ec9e16bacd
1 changed files with 15 additions and 11 deletions
26
kernel/sys.c
26
kernel/sys.c
|
@ -1630,20 +1630,21 @@ asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *r
|
||||||
asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
|
asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
|
||||||
{
|
{
|
||||||
struct rlimit new_rlim, *old_rlim;
|
struct rlimit new_rlim, *old_rlim;
|
||||||
|
unsigned long it_prof_secs;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (resource >= RLIM_NLIMITS)
|
if (resource >= RLIM_NLIMITS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
|
if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
if (new_rlim.rlim_cur > new_rlim.rlim_max)
|
if (new_rlim.rlim_cur > new_rlim.rlim_max)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
old_rlim = current->signal->rlim + resource;
|
old_rlim = current->signal->rlim + resource;
|
||||||
if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
|
if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
|
||||||
!capable(CAP_SYS_RESOURCE))
|
!capable(CAP_SYS_RESOURCE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
|
if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
retval = security_task_setrlimit(resource, &new_rlim);
|
retval = security_task_setrlimit(resource, &new_rlim);
|
||||||
if (retval)
|
if (retval)
|
||||||
|
@ -1653,19 +1654,22 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
|
||||||
*old_rlim = new_rlim;
|
*old_rlim = new_rlim;
|
||||||
task_unlock(current->group_leader);
|
task_unlock(current->group_leader);
|
||||||
|
|
||||||
if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY &&
|
if (resource != RLIMIT_CPU)
|
||||||
(cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
|
goto out;
|
||||||
new_rlim.rlim_cur <= cputime_to_secs(
|
if (new_rlim.rlim_cur == RLIM_INFINITY)
|
||||||
current->signal->it_prof_expires))) {
|
goto out;
|
||||||
|
|
||||||
|
it_prof_secs = cputime_to_secs(current->signal->it_prof_expires);
|
||||||
|
if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
|
||||||
cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur);
|
cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur);
|
||||||
|
|
||||||
read_lock(&tasklist_lock);
|
read_lock(&tasklist_lock);
|
||||||
spin_lock_irq(¤t->sighand->siglock);
|
spin_lock_irq(¤t->sighand->siglock);
|
||||||
set_process_cpu_timer(current, CPUCLOCK_PROF,
|
set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
|
||||||
&cputime, NULL);
|
|
||||||
spin_unlock_irq(¤t->sighand->siglock);
|
spin_unlock_irq(¤t->sighand->siglock);
|
||||||
read_unlock(&tasklist_lock);
|
read_unlock(&tasklist_lock);
|
||||||
}
|
}
|
||||||
|
out:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue