Commit e5a8b65b authored by Thomas Gleixner's avatar Thomas Gleixner

posix-cpu-timers: Use common permission check in posix_cpu_timer_create()

Yet another copy of the same thing gone...
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Link: https://lkml.kernel.org/r/20190821192919.505833418@linutronix.de
parent bfcf3e92
...@@ -316,44 +316,15 @@ static int posix_cpu_clock_get(const clockid_t clock, struct timespec64 *tp) ...@@ -316,44 +316,15 @@ static int posix_cpu_clock_get(const clockid_t clock, struct timespec64 *tp)
*/ */
static int posix_cpu_timer_create(struct k_itimer *new_timer) static int posix_cpu_timer_create(struct k_itimer *new_timer)
{ {
int ret = 0; struct task_struct *p = get_task_for_clock(new_timer->it_clock);
const pid_t pid = CPUCLOCK_PID(new_timer->it_clock);
struct task_struct *p;
if (CPUCLOCK_WHICH(new_timer->it_clock) >= CPUCLOCK_MAX) if (!p)
return -EINVAL; return -EINVAL;
new_timer->kclock = &clock_posix_cpu; new_timer->kclock = &clock_posix_cpu;
INIT_LIST_HEAD(&new_timer->it.cpu.entry); INIT_LIST_HEAD(&new_timer->it.cpu.entry);
rcu_read_lock();
if (CPUCLOCK_PERTHREAD(new_timer->it_clock)) {
if (pid == 0) {
p = current;
} else {
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_vpid(pid);
if (p && !has_group_leader_pid(p))
p = NULL;
}
}
new_timer->it.cpu.task = p; new_timer->it.cpu.task = p;
if (p) { return 0;
get_task_struct(p);
} else {
ret = -EINVAL;
}
rcu_read_unlock();
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment