Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3-0]: src/sys/netinet Pull up following revision(s) (requested by...



details:   https://anonhg.NetBSD.org/src/rev/26f525b3b2e6
branches:  netbsd-3-0
changeset: 579337:26f525b3b2e6
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sat Nov 11 20:49:55 2006 +0000

description:
Pull up following revision(s) (requested by reinoud in ticket #1561):
        sys/netinet/tcp_sack.c: revision 1.20
Fix alignment problems causing regular panics in tpc_sack_option on
NetBSD/alpha and NetBSD/sparc. This fixes PR#34751.
The problem most likely started to show in gcc4 and is caused by the use of
a casting to an uint32_t pointer that is later copied from using memcpy.
Gcc detects the copying of 4 bytes from an uint32_t pointer and decides to
just replace it with an aligned copy causing the trap.
Fix provided by Izumi Tsutsui and ok'd by Martin.

diffstat:

 sys/netinet/tcp_sack.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r 25a9915d9b17 -r 26f525b3b2e6 sys/netinet/tcp_sack.c
--- a/sys/netinet/tcp_sack.c    Mon Nov 06 17:28:20 2006 +0000
+++ b/sys/netinet/tcp_sack.c    Sat Nov 11 20:49:55 2006 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_sack.c,v 1.10.2.3 2005/05/11 18:08:51 tron Exp $ */
+/* $NetBSD: tcp_sack.c,v 1.10.2.3.2.1 2006/11/11 20:49:55 bouyer Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.10.2.3 2005/05/11 18:08:51 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.10.2.3.2.1 2006/11/11 20:49:55 bouyer Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -189,7 +189,7 @@
        struct sackblk *sack = NULL;
        struct sackhole *cur = NULL;
        struct sackhole *tmp = NULL;
-       u_int32_t *lp = (u_int32_t *) (cp + 2);
+       char *lp = cp + 2;
        int i, j, num_sack_blks;
        tcp_seq left, right, acked;
 
@@ -222,9 +222,9 @@
         */
        num_sack_blks = optlen / 8;
        acked = (SEQ_GT(th->th_ack, tp->snd_una)) ? th->th_ack : tp->snd_una;
-       for (i = 0; i < num_sack_blks; i++, lp += 2) {
-               memcpy(&left, lp, sizeof(*lp));
-               memcpy(&right, lp + 1, sizeof(*lp));
+       for (i = 0; i < num_sack_blks; i++, lp += sizeof(uint32_t) * 2) {
+               memcpy(&left, lp, sizeof(uint32_t));
+               memcpy(&right, lp + sizeof(uint32_t), sizeof(uint32_t));
                left = ntohl(left);
                right = ntohl(right);
 



Home | Main Index | Thread Index | Old Index