Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander H Duyck <alexander.duyck@gmail.com>
To: Wang Hai <wanghai38@huawei.com>,
	jesse.brandeburg@intel.com,  anthony.l.nguyen@intel.com,
	baijiaju1990@163.com, jeffrey.t.kirsher@intel.com,
	 davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH net] e100: Fix possible use after free in e100_xmit_prepare
Date: Wed, 16 Nov 2022 08:21:19 -0800	[thread overview]
Message-ID: <bc3077669c1f3f9bd2aca486dcbea9b508dbf318.camel@gmail.com> (raw)
In-Reply-To: <20221115172407.72863-1-wanghai38@huawei.com>

On Wed, 2022-11-16 at 01:24 +0800, Wang Hai wrote:
> In e100_xmit_prepare(), if we can't map the skb, then return -ENOMEM, so
> e100_xmit_frame() will return NETDEV_TX_BUSY and the upper layer will
> resend the skb. But the skb is already freed, which will cause UAF bug
> when the upper layer resends the skb.
> 
> Remove the harmful free.
> 
> Fixes: 5e5d49422dfb ("e100: Release skb when DMA mapping is failed in e100_xmit_prepare")
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
>  drivers/net/ethernet/intel/e100.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
> index 560d1d442232..d3fdc290937f 100644
> --- a/drivers/net/ethernet/intel/e100.c
> +++ b/drivers/net/ethernet/intel/e100.c
> @@ -1741,11 +1741,8 @@ static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
>  	dma_addr = dma_map_single(&nic->pdev->dev, skb->data, skb->len,
>  				  DMA_TO_DEVICE);
>  	/* If we can't map the skb, have the upper layer try later */
> -	if (dma_mapping_error(&nic->pdev->dev, dma_addr)) {
> -		dev_kfree_skb_any(skb);
> -		skb = NULL;
> +	if (dma_mapping_error(&nic->pdev->dev, dma_addr))
>  		return -ENOMEM;
> -	}
>  
>  	/*
>  	 * Use the last 4 bytes of the SKB payload packet as the CRC, used for

I'm surprised the original patch that this essentially reverts was even
accepted.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

      reply	other threads:[~2022-11-16 16:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15 17:24 [Intel-wired-lan] [PATCH net] e100: Fix possible use after free in e100_xmit_prepare Wang Hai
2022-11-16 16:21 ` Alexander H Duyck [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=bc3077669c1f3f9bd2aca486dcbea9b508dbf318.camel@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=baijiaju1990@163.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=jesse.brandeburg@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=wanghai38@huawei.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