lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 09 Dec 2009 09:03:18 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Thomas Gleixner <tglx@...utronix.de>
Cc:	LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>
Subject: Re: [patch 2/2] sched: Protect sched_rr_get_param access to
 task->sched_class

On Wed, 2009-12-09 at 09:00 +0100, Peter Zijlstra wrote:
> 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@...utronix.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@...llo.nl>

Oh, that was too quick, get_rr_interval_fair() actually takes the
rq->lock, so lets add this:

 unsigned int get_rr_interval_fair(struct task_struct *task)
 {
        struct sched_entity *se = &task->se;
-       unsigned long flags;
-       struct rq *rq;
        unsigned int rr_interval = 0;

        /*
         * Time slice is 0 for SCHED_OTHER tasks that are on an otherwise
         * idle runqueue:
         */
-       rq = task_rq_lock(task, &flags);
        if (rq->cfs.load.weight)
                rr_interval = NS_TO_JIFFIES(sched_slice(&rq->cfs, se));
-       task_rq_unlock(rq, &flags);
-
        return rr_interval;
 }


--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ