netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rahul Rameshbabu <rrameshbabu@nvidia.com>
To: Vadim Fedorenko <vfedorenko@novek.ru>
Cc: Vadim Fedorenko <vadfed@fb.com>, Aya Levin <ayal@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>, Gal Pressman <gal@nvidia.com>,
	Vadim Fedorenko <vadfed@meta.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net v3 2/2] mlx5: fix possible ptp queue fifo use-after-free
Date: Wed, 25 Jan 2023 17:27:06 -0800	[thread overview]
Message-ID: <87h6wejdat.fsf@nvidia.com> (raw)
In-Reply-To: <20230126010206.13483-3-vfedorenko@novek.ru> (Vadim Fedorenko's message of "Thu, 26 Jan 2023 04:02:06 +0300")

On Thu, 26 Jan, 2023 04:02:06 +0300 Vadim Fedorenko <vfedorenko@novek.ru> wrote:
> From: Vadim Fedorenko <vadfed@meta.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?

> +		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);
>  	}

  parent reply	other threads:[~2023-01-26  1:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-26  1:02 [PATCH net v3 0/2] mlx5: ptp fifo bugfixes Vadim Fedorenko
2023-01-26  1:02 ` [PATCH net v3 1/2] mlx5: fix skb leak while fifo resync and push Vadim Fedorenko
2023-01-26  6:33   ` Tariq Toukan
2023-01-26  1:02 ` [PATCH net v3 2/2] mlx5: fix possible ptp queue fifo use-after-free Vadim Fedorenko
2023-01-26  1:09   ` Rahul Rameshbabu
2023-01-26 10:53     ` Vadim Fedorenko
2023-01-26  1:27   ` Rahul Rameshbabu [this message]
2023-01-26 10:53     ` Vadim Fedorenko
2023-01-26  6:53   ` Tariq Toukan
2023-01-26 13:22     ` Vadim Fedorenko
2023-01-28 16:42   ` kernel test robot
2023-01-28 17:55   ` kernel test robot
2023-01-28 21:42   ` kernel test robot
2023-01-29  0:05   ` kernel test robot
2023-01-29 12:32   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6wejdat.fsf@nvidia.com \
    --to=rrameshbabu@nvidia.com \
    --cc=ayal@nvidia.com \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=vadfed@fb.com \
    --cc=vadfed@meta.com \
    --cc=vfedorenko@novek.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).