[PATCH] sky2: make sure ethernet header is in transmit skb
From: Stephen Hemminger
Date: Sat Dec 26 2009 - 17:07:05 EST
When DHCP sends a packet using AF_PACKET, it is possible for driver
to receive a transmit packet with the Ethernet header off in the
skb fragments. The hardware doesn't handle 0 size DMA's well,
so it gets confused.
Other drivers may have same problem, I really think this ought
to be done at higher level.
Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx>
---
Patch against net-2.6, but same patch applies to -stable as well
(with fuzz).
--- a/drivers/net/sky2.c 2009-12-26 13:39:34.289252942 -0800
+++ b/drivers/net/sky2.c 2009-12-26 13:59:44.548877690 -0800
@@ -1654,6 +1654,14 @@ static netdev_tx_t sky2_xmit_frame(struc
if (unlikely(tx_avail(sky2) < tx_le_req(skb)))
return NETDEV_TX_BUSY;
+ /* Make sure there is at least some data for first DMA */
+ if (!pskb_may_pull(skb, ETH_HLEN)) {
+ if (net_ratelimit())
+ pr_info(PFX "%s: packet missing ether header (%d)?",
+ dev->name, skb->len);
+ goto drop;
+ }
+
len = skb_headlen(skb);
mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
@@ -1799,6 +1807,7 @@ mapping_unwind:
mapping_error:
if (net_ratelimit())
dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name);
+drop:
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/