From owner-freebsd-bugs@freebsd.org Sat Apr 29 21:37:24 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D19AAD563BC for ; Sat, 29 Apr 2017 21:37:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A485A1FF2 for ; Sat, 29 Apr 2017 21:37:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v3TLbOU2096934 for ; Sat, 29 Apr 2017 21:37:24 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 218959] routed closes socket 0 when /etc/gateways in use Date: Sat, 29 Apr 2017 21:37:24 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: webpages@sprow.co.uk X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Apr 2017 21:37:24 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D218959 Bug ID: 218959 Summary: routed closes socket 0 when /etc/gateways in use Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: freebsd-bugs@FreeBSD.org Reporter: webpages@sprow.co.uk Created attachment 182180 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D182180&action= =3Dedit Patch to parms.c In the process of starting in main() routed gets=20 rt_sock =3D socket(AF_ROUTE, SOCK_RAW, 0); which on my test system is the first socket to be opened, and hence rt_sock= is 0. [https://svnweb.freebsd.org/base/head/sbin/routed/main.c?annotate=3D314436#= l309] A little further down main() we call gwkludge(), which parses the /etc/gate= ways file and adds fake interfaces for passive networks.=20 [https://svnweb.freebsd.org/base/head/sbin/routed/main.c?annotate=3D314436#= l350] Then, still in msin() we call ifinit() which looks through the interfaces k= nown and turns on router discovery and RIP=20 if_ok_rdisc(ifp); rip_on(ifp); [https://svnweb.freebsd.org/base/head/sbin/routed/if.c?annotate=3D314436#l1= 141] In the rip_on() function for any interfaces that are having RIP turned on a= ny query sockets are closed (void)close(ifp->int_rip_sock); [https://svnweb.freebsd.org/base/head/sbin/routed/main.c?annotate=3D314436#= l770] The problem is that when the fake interface was created memset was used to clear the struct interface, but the member int_rip_sock is never initialise= d. Therefore, when the loop iterates over the interfaces to turn RIP on it fin= ds a positive number (0) and closes the socket - inadvertantly closing the rt_so= ck by mistake. Patch attached initialises that member to -1, an invalid socket number. --=20 You are receiving this mail because: You are the assignee for the bug.=