netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure
Date: Tue, 23 May 2023 20:42:57 -0700	[thread overview]
Message-ID: <20230523204257.07d2512b@kernel.org> (raw)
In-Reply-To: <20230522190713.82417-1-tbogendoerfer@suse.de>

On Mon, 22 May 2023 21:07:13 +0200 Thomas Bogendoerfer wrote:
> Do skp_put() after a new skb has been successfully allocated otherwise
> the reused skb leads to skp_panics or incorrect packet sizes.

s/skp/skb/

Please add a Fixes tag pointing at the patch which introduced 
the problem (could be the first commit adding this driver).

> Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
> ---
>  .../ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c    | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
> index afa3b92a6905..2c132849a76d 100644
> --- a/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlxbf_gige/mlxbf_gige_rx.c
> @@ -245,18 +245,19 @@ static bool mlxbf_gige_rx_packet(struct mlxbf_gige *priv, int *rx_pkts)
>  
>  		skb = priv->rx_skb[rx_pi_rem];
>  
> -		skb_put(skb, datalen);
> -
> -		skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
> -
> -		skb->protocol = eth_type_trans(skb, netdev);
> -
>  		/* Alloc another RX SKB for this same index */
>  		rx_skb = mlxbf_gige_alloc_skb(priv, MLXBF_GIGE_DEFAULT_BUF_SZ,
>  					      &rx_buf_dma, DMA_FROM_DEVICE);
>  		if (!rx_skb)
>  			return false;
>  		priv->rx_skb[rx_pi_rem] = rx_skb;
> +
> +		skb_put(skb, datalen);
> +
> +		skb->ip_summed = CHECKSUM_NONE; /* device did not checksum packet */
> +
> +		skb->protocol = eth_type_trans(skb, netdev);
>
>  		dma_unmap_single(priv->dev, *rx_wqe_addr,
>  				 MLXBF_GIGE_DEFAULT_BUF_SZ, DMA_FROM_DEVICE);

You should move the code here, after the dma_unmap().
eth_type_trans() will access the payload and until dma_unmap
the data should not be accessed by the CPU.

>  		*rx_wqe_addr = rx_buf_dma;

-- 
pw-bot: cr

      reply	other threads:[~2023-05-24  3:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 19:07 [PATCH net] net: mellanox: mlxbf_gige: Fix skb_panic splat under memory pressure Thomas Bogendoerfer
2023-05-24  3:42 ` Jakub Kicinski [this message]

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=20230523204257.07d2512b@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tbogendoerfer@suse.de \
    /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).