]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: sched: fix unprotected access to rcu cookie pointer
authorVlad Buslov <vladbu@mellanox.com>
Mon, 9 Jul 2018 17:26:47 +0000 (20:26 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Jul 2018 06:01:02 +0000 (23:01 -0700)
Fix action attribute size calculation function to take rcu read lock and
access act_cookie pointer with rcu dereference.

Fixes: eec94fdb0480 ("net: sched: use rcu for action cookie update")
Reported-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_api.c

index 66dc19746c639648574067d3d52700781843caf5..148a89ab789b56bdc8117035431d827a22753494 100644 (file)
@@ -149,10 +149,15 @@ EXPORT_SYMBOL(__tcf_idr_release);
 
 static size_t tcf_action_shared_attrs_size(const struct tc_action *act)
 {
+       struct tc_cookie *act_cookie;
        u32 cookie_len = 0;
 
-       if (act->act_cookie)
-               cookie_len = nla_total_size(act->act_cookie->len);
+       rcu_read_lock();
+       act_cookie = rcu_dereference(act->act_cookie);
+
+       if (act_cookie)
+               cookie_len = nla_total_size(act_cookie->len);
+       rcu_read_unlock();
 
        return  nla_total_size(0) /* action number nested */
                + nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */