net/mlx5/core/fpga/ipsec: Fix use-after-free
Subsystems (5)
PATCH 1/1 net/mlx5/core/fpga/ipsec: Fix use-after-free
_rule_ is being freed and then dereferenced by accessing rule->ctx
Fix this by copying the value returned by PTR_ERR(rule->ctx) into a local variable for its safe use after freeing _rule_
Addresses-Coverity-ID: 1466041 ("Read from pointer after free")
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +2 -1
@@ -1061,8 +1061,9 @@ static int fpga_ipsec_fs_create_fte(struct mlx5_core_dev *dev, rule->ctx =mlx5_fpga_ipsec_fs_create_sa_ctx (dev, fte, is_egress);if (IS_ERR (rule->ctx)) { +int err =PTR_ERR (rule->ctx);kfree (rule); -return PTR_ERR (rule->ctx); +return err; } rule->fte = fte;
Signature · 1 line
2.7.4
Quoted 8 lines · Gustavo A. R. Silva
_rule_ is being freed and then dereferenced by accessing
rule->ctxFix this by copying the value returned by
PTR_ERR(rule->ctx)into a local variable for its safe use after freeing _rule_Addresses-Coverity-ID: 1466041 ("Read from pointer after free")
Fixes 05564d0ae075 ("net/mlx5: Add flow-steering commands for FPGA IPSec implementation")Signed-off-by Gustavo A. R. Silva <[email protected]>
Prefix should not be that long, a short one as this is enough.
net/mlx5: Fix use-after-free
Besides that - lgtm.
Quoted 26 lines
--- drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +2
-1@@ -1061,8 +1061,9 @@ static int fpga_ipsec_fs_create_fte(struct mlx5_core_dev *dev, rule->ctx =mlx5_fpga_ipsec_fs_create_sa_ctx (dev, fte, is_egress);if (IS_ERR (rule->ctx)) { +int err =PTR_ERR (rule->ctx);kfree (rule); -return PTR_ERR (rule->ctx); +return err; } rule->fte = fte;Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Yuval,
Quoted 12 lines · Yuval Shaia
Quoted 8 lines · Gustavo A. R. Silva
_rule_ is being freed and then dereferenced by accessing
rule->ctxFix this by copying the value returned by
PTR_ERR(rule->ctx)into a local variable for its safe use after freeing _rule_Addresses-Coverity-ID: 1466041 ("Read from pointer after free")
Fixes 05564d0ae075 ("net/mlx5: Add flow-steering commands for FPGA IPSec implementation")Signed-off-by Gustavo A. R. Silva <[email protected]>Prefix should not be that long, a short one as this is enough.
Yeah. Actually, I was suspicious about it.
Quoted 6 lines
net/mlx5: Fix use-after-free
Besides that - lgtm.
Reviewed-by Yuval Shaia <[email protected]>
I'll send v2 with a short prefix and add your Reviewed-by.
Thanks for the feedback.
--
Gustavo