This is a note to let you know that I've just added the patch titled

    sched: Use dl_bw_of() under RCU read lock

to the 3.14-stable tree which can be found at:
    
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     sched-use-dl_bw_of-under-rcu-read-lock.patch
and it can be found in the queue-3.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.


>From 66339c31bc3978d5fff9c4b4cb590a861def4db2 Mon Sep 17 00:00:00 2001
From: Kirill Tkhai <[email protected]>
Date: Mon, 22 Sep 2014 22:36:24 +0400
Subject: sched: Use dl_bw_of() under RCU read lock

From: Kirill Tkhai <[email protected]>

commit 66339c31bc3978d5fff9c4b4cb590a861def4db2 upstream.

dl_bw_of() dereferences rq->rd which has to have RCU read lock held.
Probability of use-after-free isn't zero here.

Also add lockdep assert into dl_bw_cpus().

Signed-off-by: Kirill Tkhai <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: http://lkml.kernel.org/r/20140922183624.11015.71558.stgit@localhost
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

---
 kernel/sched/core.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1895,6 +1895,8 @@ unsigned long to_ratio(u64 period, u64 r
 #ifdef CONFIG_SMP
 inline struct dl_bw *dl_bw_of(int i)
 {
+       rcu_lockdep_assert(rcu_read_lock_sched_held(),
+                          "sched RCU must be held");
        return &cpu_rq(i)->rd->dl_bw;
 }
 
@@ -1903,6 +1905,8 @@ static inline int dl_bw_cpus(int i)
        struct root_domain *rd = cpu_rq(i)->rd;
        int cpus = 0;
 
+       rcu_lockdep_assert(rcu_read_lock_sched_held(),
+                          "sched RCU must be held");
        for_each_cpu_and(i, rd->span, cpu_active_mask)
                cpus++;
 
@@ -7458,6 +7462,8 @@ static int sched_dl_global_constraints(v
        int cpu, ret = 0;
        unsigned long flags;
 
+       rcu_read_lock();
+
        /*
         * Here we want to check the bandwidth not being set to some
         * value smaller than the currently allocated bandwidth in
@@ -7479,6 +7485,8 @@ static int sched_dl_global_constraints(v
                        break;
        }
 
+       rcu_read_unlock();
+
        return ret;
 }
 
@@ -7494,6 +7502,7 @@ static void sched_dl_do_global(void)
        if (global_rt_runtime() != RUNTIME_INF)
                new_bw = to_ratio(global_rt_period(), global_rt_runtime());
 
+       rcu_read_lock();
        /*
         * FIXME: As above...
         */
@@ -7504,6 +7513,7 @@ static void sched_dl_do_global(void)
                dl_b->bw = new_bw;
                raw_spin_unlock_irqrestore(&dl_b->lock, flags);
        }
+       rcu_read_unlock();
 }
 
 static int sched_rt_global_validate(void)


Patches currently in stable-queue which might be from [email protected] are

queue-3.14/sched-use-dl_bw_of-under-rcu-read-lock.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to