Skip to content

Commit

Permalink
net: sched: fix unprotected access to rcu cookie pointer
Browse files Browse the repository at this point in the history
Fix action attribute size calculation function to take rcu read lock and
access act_cookie pointer with rcu dereference.

Fixes: eec94fd ("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>
  • Loading branch information
Vlad Buslov authored and David S. Miller committed Jul 12, 2018
1 parent 2368957 commit e0479b6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit e0479b6

Please sign in to comment.