Skip to content

Commit

Permalink
Use find_task_by_vpid in posix timers
Browse files Browse the repository at this point in the history
All the functions that need to lookup a task by pid in posix timers obtain
this pid from a user space, and thus this value refers to a task in the same
namespace, as the current task lives in.

So the proper behavior is to call find_task_by_vpid() here.

Signed-off-by: Pavel Emelyanov <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
xemul authored and Linus Torvalds committed Feb 8, 2008
1 parent 20a8143 commit 8dc86af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions kernel/posix-cpu-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static int check_clock(const clockid_t which_clock)
return 0;

read_lock(&tasklist_lock);
p = find_task_by_pid(pid);
p = find_task_by_vpid(pid);
if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ?
same_thread_group(p, current) : thread_group_leader(p))) {
error = -EINVAL;
Expand Down Expand Up @@ -305,7 +305,7 @@ int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp)
*/
struct task_struct *p;
rcu_read_lock();
p = find_task_by_pid(pid);
p = find_task_by_vpid(pid);
if (p) {
if (CPUCLOCK_PERTHREAD(which_clock)) {
if (same_thread_group(p, current)) {
Expand Down Expand Up @@ -354,15 +354,15 @@ int posix_cpu_timer_create(struct k_itimer *new_timer)
if (pid == 0) {
p = current;
} else {
p = find_task_by_pid(pid);
p = find_task_by_vpid(pid);
if (p && !same_thread_group(p, current))
p = NULL;
}
} else {
if (pid == 0) {
p = current->group_leader;
} else {
p = find_task_by_pid(pid);
p = find_task_by_vpid(pid);
if (p && !thread_group_leader(p))
p = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static struct task_struct * good_sigevent(sigevent_t * event)
struct task_struct *rtn = current->group_leader;

if ((event->sigev_notify & SIGEV_THREAD_ID ) &&
(!(rtn = find_task_by_pid(event->sigev_notify_thread_id)) ||
(!(rtn = find_task_by_vpid(event->sigev_notify_thread_id)) ||
!same_thread_group(rtn, current) ||
(event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL))
return NULL;
Expand Down

0 comments on commit 8dc86af

Please sign in to comment.