[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100514191800.3e3b6655@dhcp-lab-109.englab.brq.redhat.com>
Date: Fri, 14 May 2010 19:18:00 +0200
From: Stanislaw Gruszka <sgruszka@...hat.com>
To: Oleg Nesterov <oleg@...hat.com>, Andrey Vagin <avagin@...nvz.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org, stable@...nel.org,
Pavel Emelyanov <xemul@...nvz.org>
Subject: Re: [PATCH 2/2] posix_timer: clean up properly if anything fails
after *_timer_create
On Fri, 14 May 2010 18:03:57 +0200
Oleg Nesterov <oleg@...hat.com> wrote:
> On 05/14, Andrey Vagin wrote:
> >
> > *_timer_create may allocate/get some resources, so need call *_timer_cleanup.
> >
> > https://bugzilla.sw.ru/show_bug.cgi?id=473702
>
> Authorization Required
>
> > --- a/kernel/posix-timers.c
> > +++ b/kernel/posix-timers.c
> > @@ -574,19 +574,19 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
> > if (copy_to_user(created_timer_id,
> > &new_timer_id, sizeof (new_timer_id))) {
> > error = -EFAULT;
> > - goto out;
> > + goto out_cleanup;
> > }
> > if (timer_event_spec) {
> > if (copy_from_user(&event, timer_event_spec, sizeof (event))) {
> > error = -EFAULT;
> > - goto out;
> > + goto out_cleanup;
> > }
> > rcu_read_lock();
> > new_timer->it_pid = get_pid(good_sigevent(&event));
> > rcu_read_unlock();
> > if (!new_timer->it_pid) {
> > error = -EINVAL;
> > - goto out;
> > + goto out_cleanup;
> > }
> > } else {
> > event.sigev_notify = SIGEV_SIGNAL;
> > @@ -613,6 +613,8 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
> > * and may cease to exist at any time. Don't use or modify
> > * new_timer after the unlock call.
> > */
> > +out_cleanup:
> > + CLOCK_DISPATCH(new_timer->it_clock, timer_cleanup, (new_timer));
>
> But at first glance you are right, posix_cpu_timer_create() does
> get_task_struct(it.cpu.task).
If I understand problem correctly, seems to be fine to move
CLOCK_DISPATCH(which_clock, timer_create, (new_timer));
after all possible EFAULT errors and solve leak without creating
new timer_cleanup() callback.
Stanislaw
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists