aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sys.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index 234d9454294e..d5b79f65ad9b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1450,14 +1450,22 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
1450 return -EINVAL; 1450 return -EINVAL;
1451 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim))) 1451 if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
1452 return -EFAULT; 1452 return -EFAULT;
1453 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1454 return -EINVAL;
1455 old_rlim = current->signal->rlim + resource; 1453 old_rlim = current->signal->rlim + resource;
1456 if ((new_rlim.rlim_max > old_rlim->rlim_max) && 1454 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
1457 !capable(CAP_SYS_RESOURCE)) 1455 !capable(CAP_SYS_RESOURCE))
1458 return -EPERM; 1456 return -EPERM;
1459 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open) 1457
1460 return -EPERM; 1458 if (resource == RLIMIT_NOFILE) {
1459 if (new_rlim.rlim_max == RLIM_INFINITY)
1460 new_rlim.rlim_max = sysctl_nr_open;
1461 if (new_rlim.rlim_cur == RLIM_INFINITY)
1462 new_rlim.rlim_cur = sysctl_nr_open;
1463 if (new_rlim.rlim_max > sysctl_nr_open)
1464 return -EPERM;
1465 }
1466
1467 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1468 return -EINVAL;
1461 1469
1462 retval = security_task_setrlimit(resource, &new_rlim); 1470 retval = security_task_setrlimit(resource, &new_rlim);
1463 if (retval) 1471 if (retval)