net/mlx4_core: Use-after-free causes a resource leak in flow-steering detach
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Thu, 29 Dec 2016 16:37:09 +0000 (18:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Aug 2017 01:59:44 +0000 (18:59 -0700)
commita8820678afe1289cd35431ff847d817cdeffcadf
treea974e35b9f83c72428195dd634eb6224164bbcd6
parentaeb230318ddbfc4b06f0d4befd755090ec0c4d6f
net/mlx4_core: Use-after-free causes a resource leak in flow-steering detach

[ Upstream commit 3b01fe7f91c8e4f9afc4fae3c5af72c14958d2d8 ]

mlx4_QP_FLOW_STEERING_DETACH_wrapper first removes the steering
rule (which results in freeing the rule structure), and then
references a field in this struct (the qp number) when releasing the
busy-status on the rule's qp.

Since this memory was freed, it could reallocated and changed.
Therefore, the qp number in the struct may be incorrect,
so that we are releasing the incorrect qp. This leaves the rule's qp
in the busy state (and could possibly release an incorrect qp as well).

Fix this by saving the qp number in a local variable, for use after
removing the steering rule.

Fixes: 2c473ae7e582 ("net/mlx4_core: Disallow releasing VF QPs which have steering rules")
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c