Re: [PATCH -mm 4/7][AIO] Resend - Make good_sigevent() non-static

Oleg Nesterov
2007-02-05T13:41:25Z

On 02/05, S?bastien Dugu? wrote:
>
> +struct task_struct * sigevent_find_task(sigevent_t * event)
> +{
> + struct task_struct *task = current->group_leader;
> +
> + if ((event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
> + if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)
> + return NULL;
> + }
> +
> + if (event->sigev_notify & SIGEV_THREAD_ID) {
> + if ((event->sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_SIGNAL)
> + return NULL;
> +
> + task = find_task_by_pid(event->sigev_notify_thread_id);
> +
> + if (!task || task->tgid != current->tgid)
> + task = NULL;
> + }
> +
> + return task;
> +}

I think this patch is correct, and the code is much more readable than
the old good_sigevet().

But please don't forget that PATCH 6/7 still needs a small fixup, we can
leak a task_struct in really_put_req()

if (notify == SIGEV_THREAD_ID || notify == SIGEV_SIGNAL)
put_task_struct(req->ki_notify.target);

because without SIGEV_THREAD_ID ->sigev_notify can have any bit/bits set,
even SIGEV_NONE (along with some other bit, aio_setup_sigevent checks for
== SIGEV_NONE).

Oleg.