From owner-freebsd-net@FreeBSD.ORG Tue May 4 06:35:01 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B415216A4CF for ; Tue, 4 May 2004 06:35:01 -0700 (PDT) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71CE543D5A for ; Tue, 4 May 2004 06:35:01 -0700 (PDT) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.9p1/8.12.8) with ESMTP id i44DZ1gd038609; Tue, 4 May 2004 06:35:01 -0700 (PDT) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.9p1/8.12.3/Submit) id i44DZ1Rp038608; Tue, 4 May 2004 06:35:01 -0700 (PDT) (envelope-from rizzo) Date: Tue, 4 May 2004 06:35:00 -0700 From: Luigi Rizzo To: Colin Percival Message-ID: <20040504063500.A37862@xorpc.icir.org> References: <6.1.0.6.1.20040504133711.03d1ce18@popserver.sfu.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <6.1.0.6.1.20040504133711.03d1ce18@popserver.sfu.ca>; from colin.percival@wadham.ox.ac.uk on Tue, May 04, 2004 at 01:42:20PM +0100 cc: freebsd-net@freebsd.org Subject: Re: [patch] Verify that ifaddr_byindex(foo) != NULL X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2004 13:35:01 -0000 On Tue, May 04, 2004 at 01:42:20PM +0100, Colin Percival wrote: > Could someone confirm for me that this looks sensible? I don't > know anything about this code, but if we're going to check that > 0 < ifp->if_index <= if_index, it seems that we should also be > checking that ifp->if_index corresponds to an interface which > still exists (rather than a gap left behind when an interface was > removed). well, the problem here and elsewhere is whether we trust the rcvif field or not -- if we do, we must assume that if_index and ifadd_byindex() are all valid, because they are all set consistently in if_attach(). If the interface is gone, ifp is already bogus thus there is no point to check. So i'd vote to remove all the bogus checks here and elsewhere, rather than add newer ones. cheers luigi > Colin Percival > > Index: src/sys/netinet/ip_input.c > =================================================================== > RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v > retrieving revision 1.270 > diff -u -p -r1.270 ip_input.c > --- src/sys/netinet/ip_input.c 2 May 2004 15:10:16 -0000 1.270 > +++ src/sys/netinet/ip_input.c 4 May 2004 12:37:02 -0000 > @@ -2053,7 +2053,8 @@ ip_savecontrol(inp, mp, ip, m) > struct sockaddr_dl *sdl2 = &sdlbuf.sdl; > > if (((ifp = m->m_pkthdr.rcvif)) > - && ( ifp->if_index && (ifp->if_index <= if_index))) { > + && ( ifp->if_index && (ifp->if_index <= if_index)) && > + (ifaddr_byindex(ifp->if_index) != NULL)) { > sdp = (struct sockaddr_dl *) > (ifaddr_byindex(ifp->if_index)->ifa_addr); > /* > > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"