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: <1373932877.3745.32.camel@bwh-desktop.uk.level5networks.com>
Date:	Tue, 16 Jul 2013 01:01:17 +0100
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Neil Horman <nhorman@...driver.com>
CC:	<netdev@...r.kernel.org>, Jay Cliburn <jcliburn@...il.com>,
	Chris Snook <chris.snook@...il.com>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [net PATCH] atl1e: fix dma mapping warnings

On Fri, 2013-07-12 at 10:58 -0400, Neil Horman wrote:
[...]
> The usual straighforward failure to check for dma_mapping_error after a map
> operation is completed.
[...]
> --- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
> @@ -1665,7 +1665,7 @@ check_sum:
>  	return 0;
>  }
>  
> -static void atl1e_tx_map(struct atl1e_adapter *adapter,
> +static int atl1e_tx_map(struct atl1e_adapter *adapter,
>  		      struct sk_buff *skb, struct atl1e_tpd_desc *tpd)
>  {
>  	struct atl1e_tpd_desc *use_tpd = NULL;
> @@ -1677,6 +1677,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
>  	u16 nr_frags;
>  	u16 f;
>  	int segment;
> +	int ring_start = adapter->tx_ring.next_to_use;
>  
>  	nr_frags = skb_shinfo(skb)->nr_frags;
>  	segment = (tpd->word3 >> TPD_SEGMENT_EN_SHIFT) & TPD_SEGMENT_EN_MASK;
> @@ -1689,6 +1690,9 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
>  		tx_buffer->length = map_len;
>  		tx_buffer->dma = pci_map_single(adapter->pdev,
>  					skb->data, hdr_len, PCI_DMA_TODEVICE);
> +		if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma))
> +			return -ENOSPC;
> +

Odd choice of error code.

>  		ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE);
>  		mapped_len += map_len;
>  		use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma);
> @@ -1715,6 +1719,13 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter,
>  		tx_buffer->dma =
>  			pci_map_single(adapter->pdev, skb->data + mapped_len,
>  					map_len, PCI_DMA_TODEVICE);
> +
> +		if (dma_mapping_error(&adapter->pdev->dev, tx_buffer->dma)) {
> +			/* Reset the tx rings next pointer */
> +			adapter->tx_ring.next_to_use = ring_start;
> +			return -ENOSPC;
> +		}
[...]

This is not enough; you also need to unmap the DMA mappings that have
already been made.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ