The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH 2/4] posix-timers: fix creation race
Date: Sun, 12 Aug 2007 23:59:04 +0400	[thread overview]
Message-ID: <20070812195904.GB113@tv-sign.ru> (raw)
In-Reply-To: <20070812194455.GA113@tv-sign.ru>

On 08/12, Oleg Nesterov wrote:
>
> > > -				spin_unlock_irqrestore(&process->sighand->siglock, flags);
> > >  				process = NULL;
> > >  			}
> > > +			spin_unlock_irqrestore(&process->sighand->siglock, flags);
> 
> i'll resend this patch tomorrow. We can't do spin_unlock_irqrestore(&process->...)
> if we set process = NULL above.

Another attempt, no cleanups, just a minimal fix for now.


[PATCH 2/4] posix-timers: fix creation race

sys_timer_create() sets ->it_process and unlocks ->siglock, then checks
tmr->it_sigev_notify to define if get_task_struct() is needed.

We already passed ->it_id to the caller, another thread can delete this
timer and free its memory in between.

As a minimal fix, move this code under ->siglock, sys_timer_delete() takes
it too before calling release_posix_timer(). A proper serialization would
be to take ->it_lock, we add a partly initialized timer on posix_timers_id,
not good.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- t/kernel/posix-timers.c~	2007-08-12 23:50:46.000000000 +0400
+++ t/kernel/posix-timers.c	2007-08-12 23:52:07.000000000 +0400
@@ -547,9 +547,9 @@ sys_timer_create(const clockid_t which_c
 				new_timer->it_process = process;
 				list_add(&new_timer->list,
 					 &process->signal->posix_timers);
-				spin_unlock_irqrestore(&process->sighand->siglock, flags);
 				if (new_timer->it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
 					get_task_struct(process);
+				spin_unlock_irqrestore(&process->sighand->siglock, flags);
 			} else {
 				spin_unlock_irqrestore(&process->sighand->siglock, flags);
 				process = NULL;


  reply	other threads:[~2007-08-12 19:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-12 17:05 [PATCH 2/4] posix-timers: fix creation race Oleg Nesterov
2007-08-12 19:05 ` Thomas Gleixner
2007-08-12 19:44   ` Oleg Nesterov
2007-08-12 19:59     ` Oleg Nesterov [this message]
2007-08-13  7:35     ` Thomas Gleixner

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=20070812195904.GB113@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox