[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160129.110437.472340480320526154.davem@davemloft.net>
Date: Fri, 29 Jan 2016 11:04:37 -0800 (PST)
From: David Miller <davem@...emloft.net>
To: sowmini.varadhan@...cle.com
Cc: netdev@...r.kernel.org
Subject: Re: [RFC] Kernel unaligned access at __skb_flow_dissect
From: Sowmini Varadhan <sowmini.varadhan@...cle.com>
Date: Fri, 29 Jan 2016 13:06:51 -0500
> @@ -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);
...
> - flow_label = ip6_flowlabel(iph);
> + flow_label = ip6_flowlabel_align((const u8 *)iph);
Casting is not a foolproof solution.
The compiler is allowed to legally walk through the casts and discover that
the original type has certain alignment guarantees and use them in it's
inline expansion of memcpy().
Also, so much stuff in this file is going to trip over this issue if
the IP header isn't even 4 byte aligned.
Powered by blists - more mailing lists