All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [patch 2/2] sched: Protect sched_rr_get_param access to task->sched_class
Date: Wed, 09 Dec 2009 09:00:48 +0100	[thread overview]
Message-ID: <1260345648.5489.65.camel@laptop> (raw)
In-Reply-To: <20091208202026.804386447@linutronix.de>

On Tue, 2009-12-08 at 20:24 +0000, Thomas Gleixner wrote:
> plain text document attachment
> (sched-fix-sched-get-rr-param-race.patch)
> sched_rr_get_param calls task->sched_class->get_rr_interval(task)
> without protection against a concurrent sched_setscheduler() call
> which modifies task->sched_class.
> 
> Serialize the access with task_rq_lock(task);
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  kernel/sched.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> Index: linux-2.6-tip/kernel/sched.c
> ===================================================================
> --- linux-2.6-tip.orig/kernel/sched.c
> +++ linux-2.6-tip/kernel/sched.c
> @@ -6887,6 +6887,8 @@ SYSCALL_DEFINE2(sched_rr_get_interval, p
>  {
>  	struct task_struct *p;
>  	unsigned int time_slice;
> +	unsigned long flags;
> +	struct rq *rq;
>  	int retval;
>  	struct timespec t;
>  
> @@ -6903,7 +6905,9 @@ SYSCALL_DEFINE2(sched_rr_get_interval, p
>  	if (retval)
>  		goto out_unlock;
>  
> +	rq = task_rq_lock(p, &flags);
>  	time_slice = p->sched_class->get_rr_interval(p);
> +	task_rq_unlock(rq, &flags);
>  
>  	read_unlock(&tasklist_lock);
>  	jiffies_to_timespec(time_slice, &t);
> 

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>


  reply	other threads:[~2009-12-09  8:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 20:24 [patch 2/2] sched: Protect sched_rr_get_param access to task->sched_class Thomas Gleixner
2009-12-09  8:00 ` Peter Zijlstra [this message]
2009-12-09  8:03   ` Peter Zijlstra
2009-12-09  8:06     ` Thomas Gleixner
2009-12-09  8:32       ` [patch V2 " Thomas Gleixner
2009-12-09  8:33         ` Peter Zijlstra
2009-12-09  9:53         ` [tip:sched/urgent] sched: Protect sched_rr_get_param() " tip-bot for 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=1260345648.5489.65.camel@laptop \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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 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.