[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45e34b30-71df-d4b2-98a0-d94519723332@meta.com>
Date: Thu, 26 Jan 2023 10:53:59 +0000
From: Vadim Fedorenko <vadfed@...a.com>
To: Rahul Rameshbabu <rrameshbabu@...dia.com>
CC: Vadim Fedorenko <vadfed@...a.com>, Aya Levin <ayal@...dia.com>,
Saeed Mahameed <saeedm@...dia.com>,
Jakub Kicinski <kuba@...nel.org>,
Gal Pressman <gal@...dia.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net v3 2/2] mlx5: fix possible ptp queue fifo
use-after-free
On 26/01/2023 01:27, Rahul Rameshbabu wrote:
> On Thu, 26 Jan, 2023 04:02:06 +0300 Vadim Fedorenko <vfedorenko@...ek.ru> wrote:
>> From: Vadim Fedorenko <vadfed@...a.com>
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
>> index b72de2b520ec..4ac7483dcbcc 100644
>> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
>> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
>> @@ -94,14 +94,23 @@ static void mlx5e_ptp_skb_fifo_ts_cqe_resync(struct mlx5e_ptpsq *ptpsq, u16 skb_
>>
>> ptpsq->cq_stats->resync_event++;
>>
>> - while (skb_cc != skb_id) {
>> - skb = mlx5e_skb_fifo_pop(&ptpsq->skb_fifo);
>> + if (skb_cc > skb_id || PTP_WQE_CTR2IDX(ptpsq->skb_fifo_pc) < skb_id)
>> + pr_err_ratelimited("mlx5e: out-of-order ptp cqe\n");
>
> Lets use mlx5_core_err_rl(ptpsq->txqsq.mdev, "out-of-order ptp cqe\n") instead?
Sure, thanks for suggestion.
>
>> + return false;
>> + }
>> +
>> + while (skb_cc != skb_id && (skb = mlx5e_skb_fifo_pop(&ptpsq->skb_fifo))) {
>> hwts.hwtstamp = mlx5e_skb_cb_get_hwts(skb)->cqe_hwtstamp;
>> skb_tstamp_tx(skb, &hwts);
>> ptpsq->cq_stats->resync_cqe++;
>> napi_consume_skb(skb, budget);
>> skb_cc = PTP_WQE_CTR2IDX(ptpsq->skb_fifo_cc);
>> }
Powered by blists - more mailing lists