mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Bogdan Purcareata <bogdan.purcareata@nxp.com>
Cc: ruxandra.radulescu@nxp.com, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Subject: Re: [PATCH 1/2] staging: fsl-dpaa2/eth: Fix skb use after free
Date: Thu, 20 Jul 2017 14:17:34 +0300	[thread overview]
Message-ID: <20170720111733.vjn3i2s3shzf7u4d@mwanda> (raw)
In-Reply-To: <1500548318-23170-1-git-send-email-bogdan.purcareata@nxp.com>

On Thu, Jul 20, 2017 at 10:58:37AM +0000, Bogdan Purcareata wrote:
> Once a Tx frame descriptor is enqueued, an interrupt might be triggered
> to process the Tx confirmation and free the skb, hitting a memory use
> after free when updating the tx_bytes statistic based on skb->len.
> 
> Use the frame descriptor length instead.
> 
> Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> ---
>  drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> index b9a0a31..0f3e497 100644
> --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
> @@ -616,7 +616,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
>  		free_tx_fd(priv, &fd, NULL);
>  	} else {
>  		percpu_stats->tx_packets++;
> -		percpu_stats->tx_bytes += skb->len;
> +		percpu_stats->tx_bytes += dpaa2_fd_get_len(&fd);

This feels like the wrong thing.  Can't we just save skb->len earlier
in the function and use it here?  This is the common case right?  So
we'd be saving slightly wrong information for almost every packet.

regards,
dan carpenter

  parent reply	other threads:[~2017-07-20 11:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20 10:58 Bogdan Purcareata
2017-07-20 10:58 ` [PATCH 2/2] staging: fsl-dpaa2/eth: Error report format fixes Bogdan Purcareata
2017-07-20 11:17 ` Dan Carpenter [this message]
2017-07-20 11:38   ` [PATCH 1/2] staging: fsl-dpaa2/eth: Fix skb use after free Bogdan Purcareata
2017-07-20 11:43     ` Dan Carpenter

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=20170720111733.vjn3i2s3shzf7u4d@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=bogdan.purcareata@nxp.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ruxandra.radulescu@nxp.com \
    /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

all inboxes | Powered by JetHome®