Subject: Re: kern/27277
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
List: netbsd-bugs
Date: 01/21/2005 13:15:02
The following reply was made to PR kern/27277; it has been noted by GNATS.
From: Jean-Luc Richier <Jean-Luc.Richier@imag.fr>
To: gnats-bugs@NetBSD.org
Cc: Manuel Bouyer <bouyer@rp.lip6.fr>
Subject: Re: kern/27277
Date: Fri, 21 Jan 2005 14:14:19 +0100
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