Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23467
b: refs/heads/master
c: ec9e16b
h: refs/heads/master
i:
  23465: 89f2e5f
  23463: df36f94
v: v3
  • Loading branch information
Andrew Morton authored and Linus Torvalds committed Mar 24, 2006
1 parent 670b9e8 commit fac95a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: de62a97ef576a1f6b5013139ded9893226375bbb
refs/heads/master: ec9e16bacdba1da1ee15dd162384e22df5c87e09
26 changes: 15 additions & 11 deletions trunk/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
struct rlimit new_rlim, *old_rlim;
unsigned long it_prof_secs;
int retval;

if (resource >= RLIM_NLIMITS)
return -EINVAL;
if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
return -EFAULT;
if (new_rlim.rlim_cur > new_rlim.rlim_max)
return -EINVAL;
if (new_rlim.rlim_cur > new_rlim.rlim_max)
return -EINVAL;
old_rlim = current->signal->rlim + resource;
if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
!capable(CAP_SYS_RESOURCE))
return -EPERM;
if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
return -EPERM;
return -EPERM;

retval = security_task_setrlimit(resource, &new_rlim);
if (retval)
Expand All @@ -1653,19 +1654,22 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
*old_rlim = new_rlim;
task_unlock(current->group_leader);

if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY &&
(cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
new_rlim.rlim_cur <= cputime_to_secs(
current->signal->it_prof_expires))) {
if (resource != RLIMIT_CPU)
goto out;
if (new_rlim.rlim_cur == RLIM_INFINITY)
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);

read_lock(&tasklist_lock);
spin_lock_irq(&current->sighand->siglock);
set_process_cpu_timer(current, CPUCLOCK_PROF,
&cputime, NULL);
set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
spin_unlock_irq(&current->sighand->siglock);
read_unlock(&tasklist_lock);
}

out:
return 0;
}

Expand Down

0 comments on commit fac95a0

Please sign in to comment.