aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index f5183b08adfc..f2b2d7aa3818 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1283,10 +1283,6 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
1283 return -EFAULT; 1283 return -EFAULT;
1284 if (new_rlim.rlim_cur > new_rlim.rlim_max) 1284 if (new_rlim.rlim_cur > new_rlim.rlim_max)
1285 return -EINVAL; 1285 return -EINVAL;
1286 old_rlim = current->signal->rlim + resource;
1287 if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
1288 !capable(CAP_SYS_RESOURCE))
1289 return -EPERM;
1290 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open) 1286 if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
1291 return -EPERM; 1287 return -EPERM;
1292 1288
@@ -1304,11 +1300,16 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
1304 new_rlim.rlim_cur = 1; 1300 new_rlim.rlim_cur = 1;
1305 } 1301 }
1306 1302
1303 old_rlim = current->signal->rlim + resource;
1307 task_lock(current->group_leader); 1304 task_lock(current->group_leader);
1308 *old_rlim = new_rlim; 1305 if (new_rlim.rlim_max > old_rlim->rlim_max &&
1306 !capable(CAP_SYS_RESOURCE))
1307 retval = -EPERM;
1308 else
1309 *old_rlim = new_rlim;
1309 task_unlock(current->group_leader); 1310 task_unlock(current->group_leader);
1310 1311
1311 if (resource != RLIMIT_CPU) 1312 if (retval || resource != RLIMIT_CPU)
1312 goto out; 1313 goto out;
1313 1314
1314 /* 1315 /*
@@ -1322,7 +1323,7 @@ SYSCALL_DEFINE2(setrlimit, unsigned int, resource, struct rlimit __user *, rlim)
1322 1323
1323 update_rlimit_cpu(current, new_rlim.rlim_cur); 1324 update_rlimit_cpu(current, new_rlim.rlim_cur);
1324out: 1325out:
1325 return 0; 1326 return retval;
1326} 1327}
1327 1328
1328/* 1329/*