aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index e8819bc6f462..c3b8b1fcde0d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5128,6 +5128,7 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
5128 unsigned long flags; 5128 unsigned long flags;
5129 const struct sched_class *prev_class = p->sched_class; 5129 const struct sched_class *prev_class = p->sched_class;
5130 struct rq *rq; 5130 struct rq *rq;
5131 uid_t euid;
5131 5132
5132 /* may grab non-irq protected spin_locks */ 5133 /* may grab non-irq protected spin_locks */
5133 BUG_ON(in_interrupt()); 5134 BUG_ON(in_interrupt());
@@ -5180,8 +5181,9 @@ recheck:
5180 return -EPERM; 5181 return -EPERM;
5181 5182
5182 /* can't change other user's priorities */ 5183 /* can't change other user's priorities */
5183 if ((current->euid != p->euid) && 5184 euid = current_euid();
5184 (current->euid != p->uid)) 5185 if (euid != p->euid &&
5186 euid != p->uid)
5185 return -EPERM; 5187 return -EPERM;
5186 } 5188 }
5187 5189
@@ -5392,6 +5394,7 @@ long sched_setaffinity(pid_t pid, const cpumask_t *in_mask)
5392 cpumask_t cpus_allowed; 5394 cpumask_t cpus_allowed;
5393 cpumask_t new_mask = *in_mask; 5395 cpumask_t new_mask = *in_mask;
5394 struct task_struct *p; 5396 struct task_struct *p;
5397 uid_t euid;
5395 int retval; 5398 int retval;
5396 5399
5397 get_online_cpus(); 5400 get_online_cpus();
@@ -5412,9 +5415,9 @@ long sched_setaffinity(pid_t pid, const cpumask_t *in_mask)
5412 get_task_struct(p); 5415 get_task_struct(p);
5413 read_unlock(&tasklist_lock); 5416 read_unlock(&tasklist_lock);
5414 5417
5418 euid = current_euid();
5415 retval = -EPERM; 5419 retval = -EPERM;
5416 if ((current->euid != p->euid) && (current->euid != p->uid) && 5420 if (euid != p->euid && euid != p->uid && !capable(CAP_SYS_NICE))
5417 !capable(CAP_SYS_NICE))
5418 goto out_unlock; 5421 goto out_unlock;
5419 5422
5420 retval = security_task_setscheduler(p, 0, NULL); 5423 retval = security_task_setscheduler(p, 0, NULL);