lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 6 Apr 2012 19:08:03 +0200
From:	Arvid Brodin <arvid.brodin@...a.com>
To:	David Miller <davem@...emloft.net>
CC:	<shemminger@...tta.com>, <netdev@...r.kernel.org>,
	<balferreira@...glemail.com>, <arvid.brodin@...n.com>
Subject: Re: [RFC] net/hsr: Add support for IEC 62439-3 High-availability
 Seamless Redundancy

David Miller wrote:
> From: Arvid Brodin <arvid.brodin@...a.com>
> Date: Fri, 6 Apr 2012 17:51:24 +0200
> 
>> Just out of curiosity, what's the mechanism behind this inline
>> assignment that turns the memcpy into an unaligned access? If gcc is 
>> "smart" enough to detect a bunch of char * accesses and turn them 
>> into unaligned 32-bit accesses, isn't that a bug in gcc?
> 
> It's not doing it with "char *", it's doing it with other types like
> the type of the ICMP header in this case.
> 
> memcpy is expanded by the compiler internally into __builtin_memcpy()
> which if it sees the length is reasonably short will inline the
> copy.  And subsequently it uses the alignment of the types involved
> to determine what kinds of loads and stores it can use in that
> inline memcpy().
> 
> So the result is that just because in your case with your compiler
> it doesn't get expanded inline and fault, it doesn't mean it won't
> for someone else.
> 
> You're just lucky, and you really haven't fixed the bug.
> 

Ok. And thanks for the explanation. Would something like this do the 
trick then?

+		/* Need to cast to (char *) below to keep gcc optimizations 
+		   from causing alignment faults. */
+		memcpy(&icmp_param.data.icmph, (char *) icmp_hdr(skb),
+						sizeof(icmp_param.data.icmph));

If not, any suggestions on how to tackle this?

-- 
Arvid Brodin
Enea Services Stockholm AB - since February 16 a part of Xdin in the Alten
Group. Soon we will be working under the common brand Xdin. Read more at
www.xdin.com.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ