]> git.baikalelectronics.ru Git - kernel.git/commit
mlx5: fix possible ptp queue fifo use-after-free
authorVadim Fedorenko <vadfed@meta.com>
Thu, 2 Feb 2023 17:13:55 +0000 (09:13 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:27 +0000 (13:55 +0100)
commit65fd4cdc7f5ff55acad396f872bfb94a0ba7c054
tree95af263d61e798619c1c9ad0ab87596d8aa0dbe9
parent598f8fa5b2ee41dfefff269fb5117b01743b3209
mlx5: fix possible ptp queue fifo use-after-free

[ Upstream commit bed86be533f9beb7ad9cd2f1af65bf8796d2c3b1 ]

Fifo indexes are not checked during pop operations and it leads to
potential use-after-free when poping from empty queue. Such case was
possible during re-sync action. WARN_ON_ONCE covers future cases.

There were out-of-order cqe spotted which lead to drain of the queue and
use-after-free because of lack of fifo pointers check. Special check and
counter are added to avoid resync operation if SKB could not exist in the
fifo because of OOO cqe (skb_id must be between consumer and producer
index).

Fixes: 2037d365f6e3 ("net/mlx5e: Add resiliency for PTP TX port timestamp")
Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
drivers/net/ethernet/mellanox/mlx5/core/en/txrx.h
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h