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: <DM4PR12MB508882D5BE351BD756A7A9A4D35AA@DM4PR12MB5088.namprd12.prod.outlook.com>
Date:   Wed, 14 Jun 2023 07:15:03 +0000
From:   Jose Abreu <Jose.Abreu@...opsys.com>
To:     Christian Marangi <ansuelsmth@...il.com>,
        Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-stm32@...md-mailman.stormreply.com" 
        <linux-stm32@...md-mailman.stormreply.com>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Jose Abreu <Jose.Abreu@...opsys.com>
Subject: RE: [net-next PATCH v5 4/5] net: ethernet: stmicro: stmmac: generate
 stmmac dma conf before open

Hi Christian,

From: Christian Marangi <ansuelsmth@...il.com>
Date: Sat, Jul 23, 2022 at 15:29:32

> +static int __stmmac_open(struct net_device *dev,
> +			 struct stmmac_dma_conf *dma_conf)
>  {
>  	struct stmmac_priv *priv = netdev_priv(dev);
>  	int mode = priv->plat->phy_interface;
> -	int bfsize = 0;
>  	u32 chan;
>  	int ret;
>  
> @@ -3657,45 +3794,10 @@ static int stmmac_open(struct net_device *dev)
>  	memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
>  	priv->xstats.threshold = tc;
>  
> -	bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
> -	if (bfsize < 0)
> -		bfsize = 0;
> -
> -	if (bfsize < BUF_SIZE_16KiB)
> -		bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_conf.dma_buf_sz);
> -
> -	priv->dma_conf.dma_buf_sz = bfsize;
> -	buf_sz = bfsize;
> -
>  	priv->rx_copybreak = STMMAC_RX_COPYBREAK;
>  
> -	if (!priv->dma_conf.dma_tx_size)
> -		priv->dma_conf.dma_tx_size = DMA_DEFAULT_TX_SIZE;
> -	if (!priv->dma_conf.dma_rx_size)
> -		priv->dma_conf.dma_rx_size = DMA_DEFAULT_RX_SIZE;
> -
> -	/* Earlier check for TBS */
> -	for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++) {
> -		struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];
> -		int tbs_en = priv->plat->tx_queues_cfg[chan].tbs_en;
> -
> -		/* Setup per-TXQ tbs flag before TX descriptor alloc */
> -		tx_q->tbs |= tbs_en ? STMMAC_TBS_AVAIL : 0;
> -	}
> -
> -	ret = alloc_dma_desc_resources(priv);
> -	if (ret < 0) {
> -		netdev_err(priv->dev, "%s: DMA descriptors allocation failed\n",
> -			   __func__);
> -		goto dma_desc_error;
> -	}
> -
> -	ret = init_dma_desc_rings(dev, GFP_KERNEL);
> -	if (ret < 0) {
> -		netdev_err(priv->dev, "%s: DMA descriptors initialization failed\n",
> -			   __func__);
> -		goto init_error;
> -	}
> +	buf_sz = dma_conf->dma_buf_sz;
> +	memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));

This memcpy() needs to be the first thing to be done on __stmmac_open(), otherwise
you'll leak the dma_conf when stmmac_init_phy() fails.

Can you please send follow-up patch?

Thanks,
Jose

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ