diff options
author | Vlad Buslov <vladbu@mellanox.com> | 2018-07-09 20:26:47 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-11 23:01:02 -0700 |
commit | e0479b670d394d478907bd4fc22daab6516953c7 (patch) | |
tree | 6e8305fe6926b8dec39c9eb15e480fc18fc2cd5a /net/sched/act_api.c | |
parent | 2368957ab54d9eb14aff10b80bab1a888b092bd7 (diff) | |
download | linux-stable-e0479b670d394d478907bd4fc22daab6516953c7.tar.gz linux-stable-e0479b670d394d478907bd4fc22daab6516953c7.tar.bz2 linux-stable-e0479b670d394d478907bd4fc22daab6516953c7.zip |
net: sched: fix unprotected access to rcu cookie pointer
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>
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r-- | net/sched/act_api.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 66dc19746c63..148a89ab789b 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -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 */ |