sched: Use rcu in sys_sched_getscheduler/sys_sched_getparam()
read_lock(&tasklist_lock) does not protect sys_sched_getscheduler and sys_sched_getparam() against a concurrent update of the policy or scheduler parameters as do_sched_setscheduler() does not take the tasklist_lock. The accessed integers can be retrieved w/o locking and are snapshots anyway. Using rcu_read_lock() to protect find_task_by_vpid() and prevent the task struct from going away is not changing the above situation. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <20091209100706.753790977@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
663997d417
commit
5fe85be081
|
@ -6458,7 +6458,7 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
retval = -ESRCH;
|
retval = -ESRCH;
|
||||||
read_lock(&tasklist_lock);
|
rcu_read_lock();
|
||||||
p = find_process_by_pid(pid);
|
p = find_process_by_pid(pid);
|
||||||
if (p) {
|
if (p) {
|
||||||
retval = security_task_getscheduler(p);
|
retval = security_task_getscheduler(p);
|
||||||
|
@ -6466,7 +6466,7 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_t, pid)
|
||||||
retval = p->policy
|
retval = p->policy
|
||||||
| (p->sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0);
|
| (p->sched_reset_on_fork ? SCHED_RESET_ON_FORK : 0);
|
||||||
}
|
}
|
||||||
read_unlock(&tasklist_lock);
|
rcu_read_unlock();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6484,7 +6484,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
|
||||||
if (!param || pid < 0)
|
if (!param || pid < 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
read_lock(&tasklist_lock);
|
rcu_read_lock();
|
||||||
p = find_process_by_pid(pid);
|
p = find_process_by_pid(pid);
|
||||||
retval = -ESRCH;
|
retval = -ESRCH;
|
||||||
if (!p)
|
if (!p)
|
||||||
|
@ -6495,7 +6495,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
lp.sched_priority = p->rt_priority;
|
lp.sched_priority = p->rt_priority;
|
||||||
read_unlock(&tasklist_lock);
|
rcu_read_unlock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This one might sleep, we cannot do it with a spinlock held ...
|
* This one might sleep, we cannot do it with a spinlock held ...
|
||||||
|
@ -6505,7 +6505,7 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
read_unlock(&tasklist_lock);
|
rcu_read_unlock();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue