aboutsummaryrefslogtreecommitdiffstats
path: root/net/ethernet
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2014-01-16 18:03:31 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-16 18:30:31 -0500
commit0864c158836c2d0edb61f7128475e192b09bc851 (patch)
tree8880646ac3da6b1ab7ff5b870e63475fcb6c0aa7 /net/ethernet
parent7967919db687f1a61e3d8fbf9f5582f01c8d2cf5 (diff)
net: eth_type_trans() should use skb_header_pointer()
eth_type_trans() can read uninitialized memory as drivers do not necessarily pull more than 14 bytes in skb->head before calling it. As David suggested, we can use skb_header_pointer() to fix this without breaking some drivers that might not expect eth_type_trans() pulling 2 additional bytes. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethernet')
-rw-r--r--net/ethernet/eth.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 8f032bae60ad..5dc638cad2e1 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -156,7 +156,9 @@ EXPORT_SYMBOL(eth_rebuild_header);
156 */ 156 */
157__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) 157__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
158{ 158{
159 struct ethhdr *eth; 159 unsigned short _service_access_point;
160 const unsigned short *sap;
161 const struct ethhdr *eth;
160 162
161 skb->dev = dev; 163 skb->dev = dev;
162 skb_reset_mac_header(skb); 164 skb_reset_mac_header(skb);
@@ -194,7 +196,8 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
194 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This 196 * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
195 * won't work for fault tolerant netware but does for the rest. 197 * won't work for fault tolerant netware but does for the rest.
196 */ 198 */
197 if (unlikely(skb->len >= 2 && *(unsigned short *)(skb->data) == 0xFFFF)) 199 sap = skb_header_pointer(skb, 0, sizeof(*sap), &_service_access_point);
200 if (sap && *sap == 0xFFFF)
198 return htons(ETH_P_802_3); 201 return htons(ETH_P_802_3);
199 202
200 /* 203 /*