Skip to contentSkip to conversation

ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets

PATCH Superseded Sowmini Varadhan 2 participants 5 messages Mar 14, 2016

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets

For LLC based protocols like lldp, stp etc., the ethernet header is an 802.3 header with a h_proto that is not 0x800, 0x86dd, or even 0x806. In this world, the skb_network_header() points at the DSAP/SSAP/.. and is not likely to be NET_IP_ALIGNed in ixgbe_atr().

With LLC, drivers are not likely to correctly find IPVERSION, or "6", at hdr.ipv4->version, but will instead just needlessly trigger an unaligned access. (IPv4/IPv6 over LLC is almost never implemented).

The unaligned access is thus avoidable: bail out quickly after examining first->protocol.

---
v2: Alexander Duyck comments.

 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -0
index 4d6223d..b25e603 100644
@@ -7574,6 +7574,11 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
 	if (!ring->atr_sample_rate)
 		return;
 
+	if (first->protocol != htons(ETH_P_IP) &&
+	    first->protocol != htons(ETH_P_IPV6) &&
+	    first->protocol != htons(ETH_P_ARP))
+		return;
+
 	ring->atr_count++;
 
 	/* snag network header to get L4 type and address */
Signature · 1 line
1.7.1
#1 lore raw
Quoted 27 lines · Sowmini Varadhan

For LLC based protocols like lldp, stp etc., the ethernet header is an 802.3 header with a h_proto that is not 0x800, 0x86dd, or even 0x806. In this world, the skb_network_header() points at the DSAP/SSAP/.. and is not likely to be NET_IP_ALIGNed in ixgbe_atr().

With LLC, drivers are not likely to correctly find IPVERSION, or "6", at hdr.ipv4->version, but will instead just needlessly trigger an unaligned access. (IPv4/IPv6 over LLC is almost never implemented).

The unaligned access is thus avoidable: bail out quickly after examining first->protocol.

---
v2: Alexander Duyck comments.

 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +0 -0
index 4d6223d..b25e603 100644

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c static void ixgbe_atr(struct ixgbe_ring *ring, · line 7581

Quoted 8 lines
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -0
@@ -7574,6 +7574,11 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
        if (!ring->atr_sample_rate)
                return;
 
+       if (first->protocol != htons(ETH_P_IP) &&
+           first->protocol != htons(ETH_P_IPV6) &&
+           first->protocol != htons(ETH_P_ARP))
+               return;
+

One other thing I forgot to mention is that we don't support ARP so that check could be dropped. The ATR code only supports IPv4 or IPv6 with TCP.

- Alex

#2 lore raw
Quoted 4 lines · Alexander Duyck

One other thing I forgot to mention is that we don't support ARP so that check could be dropped. The ATR code only supports IPv4 or IPv6 with TCP.

I did notice that, but I left it in place because (a) it comes down the stack with the NET_IP_ALIGNment and (b) ARP is only sent over Ethernet II (there is no LLC SAP for ARP, which is a big reason why ipv4 is not sent over llc, despite rfc 1042).

I figured it would not hurt to pass it down, in case we decide to do something clever with it in the future.

--Sowmini

#3 lore raw
Quoted 6 lines · Sowmini Varadhan
Quoted 4 lines · Alexander Duyck

One other thing I forgot to mention is that we don't support ARP so that check could be dropped. The ATR code only supports IPv4 or IPv6 with TCP.

Quoted 7 lines

I did notice that, but I left it in place because (a) it comes down the stack with the NET_IP_ALIGNment and (b) ARP is only sent over Ethernet II (there is no LLC SAP for ARP, which is a big reason why ipv4 is not sent over llc, despite rfc 1042).

I figured it would not hurt to pass it down, in case we decide to do something clever with it in the future.

I figure it is better to just drop it since we don't need to be trying to parse ARP packets anyway.

- Alex

#4 lore raw
Quoted 2 lines · Alexander Duyck

I figure it is better to just drop it since we don't need to be trying to parse ARP packets anyway.

Ok, let me send out v3.