All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: ena: Fix use of uninitialized DMA address bits field
@ 2018-07-26 20:40 Gal Pressman
  2018-07-27  4:31 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Gal Pressman @ 2018-07-26 20:40 UTC (permalink / raw)
  To: netdev, Netanel Belgazal; +Cc: Gal Pressman

UBSAN triggers the following undefined behaviour warnings:
[...]
[   13.236124] UBSAN: Undefined behaviour in drivers/net/ethernet/amazon/ena/ena_eth_com.c:468:22
[   13.240043] shift exponent 64 is too large for 64-bit type 'long long unsigned int'
[...]
[   13.744769] UBSAN: Undefined behaviour in drivers/net/ethernet/amazon/ena/ena_eth_com.c:373:4
[   13.748694] shift exponent 64 is too large for 64-bit type 'long long unsigned int'
[...]

When splitting the address to high and low, GENMASK_ULL is used to generate
a bitmask with dma_addr_bits field from io_sq (in ena_com_prepare_tx and
ena_com_add_single_rx_desc).
The problem is that dma_addr_bits is not initialized with a proper value
(besides being cleared in ena_com_create_io_queue).
Assign dma_addr_bits the correct value that is stored in ena_dev when
initializing the SQ.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Gal Pressman <pressmangal@gmail.com>
---
 drivers/net/ethernet/amazon/ena/ena_com.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index 1b9d3130af4d..17f12c18d225 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -333,6 +333,7 @@ static int ena_com_init_io_sq(struct ena_com_dev *ena_dev,
 
 	memset(&io_sq->desc_addr, 0x0, sizeof(io_sq->desc_addr));
 
+	io_sq->dma_addr_bits = ena_dev->dma_addr_bits;
 	io_sq->desc_entry_size =
 		(io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
 		sizeof(struct ena_eth_io_tx_desc) :
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: ena: Fix use of uninitialized DMA address bits field
  2018-07-26 20:40 [PATCH net] net: ena: Fix use of uninitialized DMA address bits field Gal Pressman
@ 2018-07-27  4:31 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-27  4:31 UTC (permalink / raw)
  To: pressmangal; +Cc: netdev, netanel

From: Gal Pressman <pressmangal@gmail.com>
Date: Thu, 26 Jul 2018 23:40:33 +0300

> UBSAN triggers the following undefined behaviour warnings:
> [...]
> [   13.236124] UBSAN: Undefined behaviour in drivers/net/ethernet/amazon/ena/ena_eth_com.c:468:22
> [   13.240043] shift exponent 64 is too large for 64-bit type 'long long unsigned int'
> [...]
> [   13.744769] UBSAN: Undefined behaviour in drivers/net/ethernet/amazon/ena/ena_eth_com.c:373:4
> [   13.748694] shift exponent 64 is too large for 64-bit type 'long long unsigned int'
> [...]
> 
> When splitting the address to high and low, GENMASK_ULL is used to generate
> a bitmask with dma_addr_bits field from io_sq (in ena_com_prepare_tx and
> ena_com_add_single_rx_desc).
> The problem is that dma_addr_bits is not initialized with a proper value
> (besides being cleared in ena_com_create_io_queue).
> Assign dma_addr_bits the correct value that is stored in ena_dev when
> initializing the SQ.
> 
> Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
> Signed-off-by: Gal Pressman <pressmangal@gmail.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-27  5:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 20:40 [PATCH net] net: ena: Fix use of uninitialized DMA address bits field Gal Pressman
2018-07-27  4:31 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.