All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Vagin <avagin@gmail.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>,
	Andrey Vagin <avagin@openvz.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, stable@kernel.org,
	Pavel Emelyanov <xemul@openvz.org>
Subject: Re: [PATCH 2/2] posix_timer: clean up properly if anything fails after *_timer_create
Date: Sat, 15 May 2010 18:17:17 +0400	[thread overview]
Message-ID: <4BEEACED.8030004@gmail.com> (raw)
In-Reply-To: <20100514184850.GA11352@redhat.com>

On 05/14/2010 10:48 PM, Oleg Nesterov wrote:
> On 05/14, Stanislaw Gruszka wrote:
>    
>> On Fri, 14 May 2010 18:03:57 +0200
>> Oleg Nesterov<oleg@redhat.com>  wrote:
>>
>>      
>>> On 05/14, Andrey Vagin wrote:
>>>        
>>>> @@ -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.
>>      
> I thought about this too, we are doing copy_to_user(created_timer_id)
> "in advance" anyway. Probably we can move all this code block
>
> 	new_timer->it_id = (timer_t) new_timer_id;
> 	new_timer->it_clock = which_clock;
> 	new_timer->it_overrun = -1;
> 	error = CLOCK_DISPATCH(which_clock, timer_create, (new_timer));
> 	if (error)
> 		goto out;
>
> down, right before we take ->siglock.
>    
You are right. I will send a new patch sooner. Thanks for your comments.
> But I don't understand the change in posix_cpu_timer_del() from 1/2.
>    
timer_cleanup doesn't do the disarm timer. In case fail in timer_create 
it's enough to call timer_cleanup. This changes are not necessary in new 
version.
>
> Otoh, currently "The next step is hard to back out if there is an error"
> comment is not right, release_posix_timer() does put_pid(). We can
> move copy_to_user(created_timer_id) down after "if (timer_event_spec)"
> block too. (but before CLOCK_DISPATCH(), of course).
>
> Andrey, what do you think?
>    
I've look at code again and think that you are right. At first I created 
patches for 2.6.18 kernel, more complex code in this place and the 
comment "the next step is ..." induced me to make callback timer_cleanup.
> Oleg.
>
>    


  reply	other threads:[~2010-05-15 14:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14 13:28 [PATCH 1/2] posix_timer: separate timer_cleanup from timer_del Andrey Vagin
2010-05-14 13:28 ` [PATCH 2/2] posix_timer: clean up properly if anything fails after *_timer_create Andrey Vagin
2010-05-14 16:03   ` Oleg Nesterov
2010-05-14 17:18     ` Stanislaw Gruszka
2010-05-14 18:48       ` Oleg Nesterov
2010-05-15 14:17         ` Andrew Vagin [this message]
2010-05-14 16:01 ` [PATCH 1/2] posix_timer: separate timer_cleanup from timer_del Oleg Nesterov
2010-05-24 21:40 ` [stable] " Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BEEACED.8030004@gmail.com \
    --to=avagin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=sgruszka@redhat.com \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.