lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241029150137.20dc8aab@kernel.org>
Date: Tue, 29 Oct 2024 15:01:37 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Stefan Wahren <wahrenst@....net>
Cc: Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni
 <pabeni@...hat.com>, Dan Carpenter <dan.carpenter@...aro.org>,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
 stable@...r.kernel.org, Simon Horman <horms@...nel.org>
Subject: Re: [PATCH net] net: vertexcom: mse102x: Fix possible double free
 of TX skb

On Tue, 29 Oct 2024 22:15:15 +0100 Stefan Wahren wrote:
> > Isn't it easier to change this function to free the copy rather than
> > the original? That way the original will remain valid for the callers.  
> You mean something like this?
> 
> diff --git a/drivers/net/ethernet/vertexcom/mse102x.c
> b/drivers/net/ethernet/vertexcom/mse102x.c
> index a04d4073def9..2c37957478fb 100644
> --- a/drivers/net/ethernet/vertexcom/mse102x.c
> +++ b/drivers/net/ethernet/vertexcom/mse102x.c
> @@ -222,7 +222,7 @@ static int mse102x_tx_frame_spi(struct mse102x_net
> *mse, struct sk_buff *txp,
>       struct mse102x_net_spi *mses = to_mse102x_spi(mse);
>       struct spi_transfer *xfer = &mses->spi_xfer;
>       struct spi_message *msg = &mses->spi_msg;
> -    struct sk_buff *tskb;
> +    struct sk_buff *tskb = NULL;
>       int ret;
> 
>       netif_dbg(mse, tx_queued, mse->ndev, "%s: skb %p, %d@%p\n",
> @@ -235,7 +235,6 @@ static int mse102x_tx_frame_spi(struct mse102x_net
> *mse, struct sk_buff *txp,
>           if (!tskb)
>               return -ENOMEM;
> 
> -        dev_kfree_skb(txp);
>           txp = tskb;
>       }
> 
> @@ -257,6 +256,8 @@ static int mse102x_tx_frame_spi(struct mse102x_net
> *mse, struct sk_buff *txp,
>           mse->stats.xfer_err++;
>       }
> 
> +    dev_kfree_skb(tskb);
> +
>       return ret;
>   }

Exactly, I think it would work and it feels simpler.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ