Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eebfb643 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller
Browse files

sh_eth: Fix padding of short frames on TX



If an skb to be transmitted is shorter than the minimum Ethernet frame
length, we currently set the DMA descriptor length to the minimum but
do not add zero-padding.  This could result in leaking sensitive
data.  We also pass different lengths to dma_map_single() and
dma_unmap_single().

Use skb_padto() to pad properly, before calling dma_map_single().

Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02a54164
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2117,6 +2117,9 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
	}
	spin_unlock_irqrestore(&mdp->lock, flags);

	if (skb_padto(skb, ETH_ZLEN))
		return NETDEV_TX_OK;

	entry = mdp->cur_tx % mdp->num_tx_ring;
	mdp->tx_skbuff[entry] = skb;
	txdesc = &mdp->tx_ring[entry];
@@ -2126,9 +2129,6 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
				 skb->len + 2);
	txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len,
				      DMA_TO_DEVICE);
	if (skb->len < ETH_ZLEN)
		txdesc->buffer_length = ETH_ZLEN;
	else
	txdesc->buffer_length = skb->len;

	if (entry >= mdp->num_tx_ring - 1)