netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Kernel unaligned access at __skb_flow_dissect
@ 2016-01-29 18:06 Sowmini Varadhan
  2016-01-29 18:33 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 50+ messages in thread
From: Sowmini Varadhan @ 2016-01-29 18:06 UTC (permalink / raw)
  To: netdev


There is an unaligned access at __skb_flow_dissect when it calls
ip6_flowlabel() with the call stack

  __skb_flow_dissect+0x2a8/0x87c
  eth_get_headlen+0x5c/0xaxa4
  ixgbe_clean_rx_irq+0x5cc/0xb20 [ixgbe]
  ixgbe_poll+0x5a4/0x760 [ixgbe]
  net_rx_action+0x13c/0x354
    :

Essentially, ixgbe_pull_tail() is trying to figure out how much
to pull, in order to have an aligned buffer:

        pull_len = eth_get_headlen(va, IXGBE_RX_HDR_SIZE);

        /* align pull length to size of long to optimize memcpy performance */
        skb_copy_to_linear_data(skb, va, ALIGN(pull_len, sizeof(long)));

and seems like the unaligned access is unavoidable here (see comments
in __skb_get_poff, for example).

This (below) is what I came up with, to get rid of the unaligned access
errors on sparc, Is there a better solution? (Not having access
to struct ip6_hdr in this file made put_unaligned usage non-obvious)


--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -102,6 +102,17 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int 
 }
 EXPORT_SYMBOL(__skb_flow_get_ports);
 
+static inline __be32 ip6_flowlabel_align(const u8 *hdr)
+{
+       union {
+               __u8 w[4];
+               __u32 flow;
+       } ip6_flow;
+
+       memcpy(ip6_flow.w, hdr, 4);
+       return (ip6_flow.flow & IPV6_FLOWLABEL_MASK);
+}
+
 /**
  * __skb_flow_dissect - extract the flow_keys struct and return it
  * @skb: sk_buff to extract the flow from, can be NULL if the rest are specifie
@@ -230,7 +241,7 @@ ipv6:
                        key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
                }
 
-               flow_label = ip6_flowlabel(iph);
+               flow_label = ip6_flowlabel_align((const u8 *)iph);
                if (flow_label) {
                        if (dissector_uses_key(flow_dissector,
                                               FLOW_DISSECTOR_KEY_FLOW_LABEL)) {

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

end of thread, other threads:[~2016-02-02  9:50 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-29 18:06 [RFC] Kernel unaligned access at __skb_flow_dissect Sowmini Varadhan
2016-01-29 18:33 ` Eric Dumazet
2016-01-29 18:40   ` Eric Dumazet
2016-01-29 19:08     ` David Miller
2016-01-29 19:39       ` Eric Dumazet
2016-01-29 18:54   ` Eric Dumazet
2016-01-29 19:22     ` Sowmini Varadhan
2016-01-29 21:00     ` Tom Herbert
2016-01-29 21:09       ` Sowmini Varadhan
2016-01-29 21:33         ` Tom Herbert
2016-01-29 23:00         ` Tom Herbert
2016-01-29 23:04           ` Sowmini Varadhan
2016-01-29 23:31             ` Tom Herbert
2016-01-29 23:58               ` Sowmini Varadhan
2016-01-30  0:47                 ` Tom Herbert
2016-01-30  1:18                   ` David Miller
2016-01-30  2:15                   ` Eric Dumazet
2016-01-31 22:13                     ` Tom Herbert
2016-02-01  0:04                       ` Eric Dumazet
2016-01-29 19:06   ` David Miller
2016-01-29 19:37     ` Eric Dumazet
2016-01-29 19:41       ` David Miller
2016-01-29 19:44       ` Sowmini Varadhan
2016-01-29 20:01         ` Eric Dumazet
2016-01-29 20:06           ` Eric Dumazet
2016-01-29 21:16           ` Alexander Duyck
2016-01-29 21:33             ` Eric Dumazet
2016-01-29 22:08               ` Alexander Duyck
2016-01-29 22:28                 ` Eric Dumazet
2016-01-29 23:00                   ` Alexander Duyck
2016-02-01 16:55                   ` David Laight
2016-02-01 17:25                     ` Eric Dumazet
2016-01-29 19:04 ` David Miller
2016-01-30  2:49 ` [net PATCH] flow_dissector: Fix unaligned access in __skb_flow_dissector when used by eth_get_headlen Alexander Duyck
2016-01-30  3:23   ` Eric Dumazet
2016-01-30  3:35     ` David Miller
2016-01-30  4:46       ` Alexander Duyck
2016-01-30 16:17     ` Sowmini Varadhan
2016-01-30 17:43       ` Tom Herbert
2016-01-30 19:12         ` Sowmini Varadhan
2016-01-30 18:36       ` Alexander Duyck
2016-01-30 19:26         ` Eric Dumazet
2016-01-31  1:13           ` Alexander Duyck
2016-01-31  3:45             ` David Miller
2016-01-31  9:12               ` Alexander Duyck
2016-01-31 19:17                 ` David Miller
2016-01-31 21:23                   ` Sowmini Varadhan
2016-02-01 16:50               ` David Laight
2016-02-01 18:18                 ` Alexander Duyck
2016-02-02  9:47                   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).