netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net: alignment problem in icmp code
@ 2007-10-20 21:35 Pierre Ossman
  2007-10-21  5:12 ` David Miller
  0 siblings, 1 reply; 14+ messages in thread
From: Pierre Ossman @ 2007-10-20 21:35 UTC (permalink / raw)
  To: davem, netdev

[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]

Structure assignment have to be aligned just like any assignment, and the skb could point to anything. So take the safe route and use a memcpy().

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
---

diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 272c69e..a7e2ec9 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -783,7 +783,7 @@ static void icmp_echo(struct sk_buff *skb)
 	if (!sysctl_icmp_echo_ignore_all) {
 		struct icmp_bxm icmp_param;
 
-		icmp_param.data.icmph	   = *icmp_hdr(skb);
+		memcpy(&icmp_param.data.icmph, icmp_hdr(skb), sizeof(struct icmphdr));
 		icmp_param.data.icmph.type = ICMP_ECHOREPLY;
 		icmp_param.skb		   = skb;
 		icmp_param.offset	   = 0;
@@ -819,7 +819,7 @@ static void icmp_timestamp(struct sk_buff *skb)
 	icmp_param.data.times[2] = icmp_param.data.times[1];
 	if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
 		BUG();
-	icmp_param.data.icmph	   = *icmp_hdr(skb);
+	memcpy(&icmp_param.data.icmph, icmp_hdr(skb), sizeof(struct icmphdr));
 	icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
 	icmp_param.data.icmph.code = 0;
 	icmp_param.skb		   = skb;

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2007-10-22  9:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-20 21:35 net: alignment problem in icmp code Pierre Ossman
2007-10-21  5:12 ` David Miller
2007-10-21  9:34   ` Pierre Ossman
2007-10-21 19:48     ` David Miller
2007-10-21 21:21       ` Pierre Ossman
2007-10-21 23:02         ` David Miller
2007-10-22  4:54           ` Pierre Ossman
2007-10-22  5:15             ` David Miller
2007-10-22  7:23               ` Pierre Ossman
2007-10-22  8:31                 ` David Miller
2007-10-22  8:42                   ` Pierre Ossman
2007-10-22  9:05                     ` David Miller
2007-10-22  9:26                       ` Pierre Ossman
2007-10-22  9:52                         ` Eric Dumazet

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).