public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel•org>
To: Ma Ke <make_ruc2021@163•com>
Cc: shshaikh@marvell•com, manishc@marvell•com, davem@davemloft•net,
	edumazet@google•com, kuba@kernel•org, pabeni@redhat•com,
	GR-Linux-NIC-Dev@marvell•com, netdev@vger•kernel.org,
	linux-kernel@vger•kernel.org
Subject: Re: [PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb()
Date: Fri, 15 Sep 2023 07:45:41 +0200	[thread overview]
Message-ID: <20230915054541.GB758782@kernel.org> (raw)
In-Reply-To: <20230913104119.3344592-1-make_ruc2021@163.com>

On Wed, Sep 13, 2023 at 06:41:19PM +0800, Ma Ke wrote:
> In qlcnic_alloc_rx_skb(), when dma_map_single() fails, skb is freed
> immediately. And skb could be freed again. This issue could allow a
> local attacker to crash the system due to a use-after-free flaw.
> 
> Signed-off-by: Ma Ke <make_ruc2021@163•com>
> ---
>  drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> index 41894d154013..6501aaf2b5ce 100644
> --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
> @@ -832,6 +832,7 @@ static int qlcnic_alloc_rx_skb(struct qlcnic_adapter *adapter,
>  	if (dma_mapping_error(&pdev->dev, dma)) {
>  		adapter->stats.rx_dma_map_error++;
>  		dev_kfree_skb_any(skb);
> +		skb = NULL;
>  		return -ENOMEM;

Hi Ma Ke,

I am a unclear on how skb could be freed a second time.
skb is a local variable which goes out of scope when
the function returns.

      reply	other threads:[~2023-09-15  5:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-13 10:41 [PATCH] net/qlcnic: fix possible use-after-free bugs in qlcnic_alloc_rx_skb() Ma Ke
2023-09-15  5:45 ` Simon Horman [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=20230915054541.GB758782@kernel.org \
    --to=horms@kernel$(echo .)org \
    --cc=GR-Linux-NIC-Dev@marvell$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=make_ruc2021@163$(echo .)com \
    --cc=manishc@marvell$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=shshaikh@marvell$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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