Skip to content

Commit d9c70e9

Browse files
Dan CarpenterPaolo Abeni
authored andcommitted
octeontx2-pf: Fix potential use after free in otx2_tc_add_flow()
This code calls kfree_rcu(new_node, rcu) and then dereferences "new_node" and then dereferences it on the next line. Two lines later, we take a mutex so I don't think this is an RCU safe region. Re-order it to do the dereferences before queuing up the free. Fixes: 68fbff6 ("octeontx2-pf: Add police action for TC flower") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/aNKCL1jKwK8GRJHh@stanley.mountain Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 764a47a commit d9c70e9

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/ethernet/marvell/octeontx2/nic

1 file changed

+1
-1
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,6 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
13261326

13271327
free_leaf:
13281328
otx2_tc_del_from_flow_list(flow_cfg, new_node);
1329-
kfree_rcu(new_node, rcu);
13301329
if (new_node->is_act_police) {
13311330
mutex_lock(&nic->mbox.lock);
13321331

@@ -1346,6 +1345,7 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
13461345

13471346
mutex_unlock(&nic->mbox.lock);
13481347
}
1348+
kfree_rcu(new_node, rcu);
13491349

13501350
return rc;
13511351
}

0 commit comments

Comments
 (0)