mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
octeontx2-pf: Fix potential use after free in otx2_tc_add_flow()
[ Upstream commitd9c70e93ec] 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:68fbff68db("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ca74b67b47
commit
c41b2941a0
@@ -1319,7 +1319,6 @@ static int otx2_tc_add_flow(struct otx2_nic *nic,
|
||||
|
||||
free_leaf:
|
||||
otx2_tc_del_from_flow_list(flow_cfg, new_node);
|
||||
kfree_rcu(new_node, rcu);
|
||||
if (new_node->is_act_police) {
|
||||
mutex_lock(&nic->mbox.lock);
|
||||
|
||||
@@ -1339,6 +1338,7 @@ free_leaf:
|
||||
|
||||
mutex_unlock(&nic->mbox.lock);
|
||||
}
|
||||
kfree_rcu(new_node, rcu);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user