Skip to content

Commit e0479b6

Browse files
w1ldptrdavem330
authored andcommitted
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: 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>
1 parent 2368957 commit e0479b6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

net/sched/act_api.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,15 @@ EXPORT_SYMBOL(__tcf_idr_release);
149149

150150
static size_t tcf_action_shared_attrs_size(const struct tc_action *act)
151151
{
152+
struct tc_cookie *act_cookie;
152153
u32 cookie_len = 0;
153154

154-
if (act->act_cookie)
155-
cookie_len = nla_total_size(act->act_cookie->len);
155+
rcu_read_lock();
156+
act_cookie = rcu_dereference(act->act_cookie);
157+
158+
if (act_cookie)
159+
cookie_len = nla_total_size(act_cookie->len);
160+
rcu_read_unlock();
156161

157162
return nla_total_size(0) /* action number nested */
158163
+ nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */

0 commit comments

Comments
 (0)