Subject: [Jean-Luc.Richier@imag.fr: Re: kern/27277]
To: None <tech-net@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-net
Date: 01/21/2005 19:42:42
Hi,
in case some of you isn't subscribed to netbsd-bugs@ ...
Any comment about this ? Is it OK to commit ?


----- Forwarded message from Jean-Luc Richier <Jean-Luc.Richier@imag.fr> -----

Date: Fri, 21 Jan 2005 14:14:19 +0100
From: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
Subject: Re: kern/27277
To: gnats-bugs@NetBSD.org
CC: Manuel Bouyer <bouyer@rp.lip6.fr>
User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.4.3) Gecko/20041005

The gif problem reported in kern/27277 (gif tunnels do not work in IPv6) 
is still in NetBSD 2.0.
It is also in kame source (kame/kame/sys/netinet/ip_encap.c)

The reason is a bad initialisation of a structure: a buffer is allocated
and filled with a mask, but the kernel code forget to do a bzero on the
unused fields. Therefore the mask is incorrect and the search for a 
matching gif interface fails
To correct apply the following patch - on NetBSD2.0, but also in 
NetBSD-current and in KAME snapshots:
(I am not sure that the M_ZERO is needed for the addrpack field, but
 I prefer to avoid uninitialized fields)


--- sys/netinet/ip_encap.c.DIST 2004-03-04 16:15:06.000000000 +0100
+++ sys/netinet/ip_encap.c      2005-01-04 22:31:07.000000000 +0100
@@ -597,12 +597,12 @@
                goto fail;
        }
        bzero(ep, sizeof(*ep));
-       ep->addrpack = malloc(l, M_NETADDR, M_NOWAIT);
+       ep->addrpack = malloc(l, M_NETADDR, M_NOWAIT|M_ZERO);
        if (ep->addrpack == NULL) {
                error = ENOBUFS;
                goto gc;
        }
-       ep->maskpack = malloc(l, M_NETADDR, M_NOWAIT);
+       ep->maskpack = malloc(l, M_NETADDR, M_NOWAIT|M_ZERO);
        if (ep->maskpack == NULL) {
                error = ENOBUFS;
                goto gc;





-- 
Jean-Luc RICHIER (Jean-Luc.Richier@Imag.Fr  richier@imag.fr)
Laboratoire Logiciels, Systemes et Reseaux (LSR-IMAG)
IMAG-CAMPUS, BP 72, F-38402 St Martin d'Heres Cedex
Tel : +33 4 76 82 72 32 Fax : +33 4 76 82 72 87

----- End forwarded message -----
-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 26 ans d'experience feront toujours la difference
--