aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index c3c718aea618..155a33da7aa7 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4116,27 +4116,25 @@ recheck:
4116 * Allow unprivileged RT tasks to decrease priority: 4116 * Allow unprivileged RT tasks to decrease priority:
4117 */ 4117 */
4118 if (!capable(CAP_SYS_NICE)) { 4118 if (!capable(CAP_SYS_NICE)) {
4119 unsigned long rlim_rtprio; 4119 if (is_rt_policy(policy)) {
4120 unsigned long flags; 4120 unsigned long rlim_rtprio;
4121 4121 unsigned long flags;
4122 if (!lock_task_sighand(p, &flags)) 4122
4123 return -ESRCH; 4123 if (!lock_task_sighand(p, &flags))
4124 rlim_rtprio = p->signal->rlim[RLIMIT_RTPRIO].rlim_cur; 4124 return -ESRCH;
4125 unlock_task_sighand(p, &flags); 4125 rlim_rtprio = p->signal->rlim[RLIMIT_RTPRIO].rlim_cur;
4126 unlock_task_sighand(p, &flags);
4127
4128 /* can't set/change the rt policy */
4129 if (policy != p->policy && !rlim_rtprio)
4130 return -EPERM;
4131
4132 /* can't increase priority */
4133 if (param->sched_priority > p->rt_priority &&
4134 param->sched_priority > rlim_rtprio)
4135 return -EPERM;
4136 }
4126 4137
4127 /*
4128 * can't change policy, except between SCHED_NORMAL
4129 * and SCHED_BATCH:
4130 */
4131 if (((policy != SCHED_NORMAL && p->policy != SCHED_BATCH) &&
4132 (policy != SCHED_BATCH && p->policy != SCHED_NORMAL)) &&
4133 !rlim_rtprio)
4134 return -EPERM;
4135 /* can't increase priority */
4136 if (is_rt_policy(policy) &&
4137 param->sched_priority > p->rt_priority &&
4138 param->sched_priority > rlim_rtprio)
4139 return -EPERM;
4140 /* can't change other user's priorities */ 4138 /* can't change other user's priorities */
4141 if ((current->euid != p->euid) && 4139 if ((current->euid != p->euid) &&
4142 (current->euid != p->uid)) 4140 (current->euid != p->uid))