From owner-freebsd-stable@freebsd.org Thu Oct 26 22:17:03 2017 Return-Path: Delivered-To: freebsd-stable@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 DE0A7E54262 for ; Thu, 26 Oct 2017 22:17:03 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [78.47.246.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 856036B97F for ; Thu, 26 Oct 2017 22:17:02 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (root@eg.sd.rdtc.ru [62.231.161.221] (may be forged)) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id v9QMGv0p035100 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 27 Oct 2017 00:16:58 +0200 (CEST) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: mike@sentex.net Received: from [10.58.0.4] ([10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id v9QMGrhP014492 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 27 Oct 2017 05:16:53 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: ppp routing bug ? To: Mike Tancsa , FreeBSD-STABLE Mailing List References: <59F1B650.5070107@grosbein.net> <22c3cbd4-2a8e-884f-ec9b-cc4d12ff818f@sentex.net> <59F1EA48.1090500@grosbein.net> <59F206CB.5000006@grosbein.net> <98f44309-d706-4cef-c0b2-0f08e0e1855c@sentex.net> From: Eugene Grosbein Message-ID: <59F25ED0.1010001@grosbein.net> Date: Fri, 27 Oct 2017 05:16:48 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <98f44309-d706-4cef-c0b2-0f08e0e1855c@sentex.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00, LOCAL_FROM, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 1.9 RDNS_NONE Delivered to internal network by a host with no rDNS * 2.6 LOCAL_FROM From my domains X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hz.grosbein.net X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 22:17:04 -0000 27.10.2017 1:04, Mike Tancsa пишет: > On 10/26/2017 12:01 PM, Eugene Grosbein wrote: >> >> I would re-run ppp under ktrace to make sure while having "route monitor" running around. >> Then compare pids with kdump output. > > I wonder if I copied and pasted from 2 different test sessions. Anyways, > same PID when I re-ran the test and more importantly the same results > (see pid.txt). The HOST flag is missing for some reason when the route > is added by ppp vs via the shell > > 29597 is the ppp process > > > the borked route monitor looks like > > got message of size 124 on Thu Oct 26 12:21:12 2017 > RTM_ADD: Add Route: len 124, pid: 29597, seq 2, errno 0, > flags: > locks: inits: > sockaddrs: > 192.168.134.2 64.7.128.7 > > > got message of size 196 on Thu Oct 26 12:21:13 2017 > RTM_CHANGE: Change Metrics or flags: len 196, pid: 29597, seq 5, errno > 0, flags: > locks: inits: > sockaddrs: > 192.168.134.2 64.7.128.7 tun0 98-159-244-185.agas1a-dynamic.dsl.sentex.ca > > vs the one that works > > got message of size 124 on Thu Oct 26 12:21:13 2017 > RTM_ADD: Add Route: len 124, pid: 29877, seq 1, errno 0, > flags: > locks: inits: > sockaddrs: > 192.168.136.1 64.7.128.7 > > > got message of size 196 on Thu Oct 26 12:21:13 2017 > RTM_CHANGE: Change Metrics or flags: len 196, pid: 29597, seq 8, errno > 0, flags: > locks: inits: > sockaddrs: > 192.168.136.1 64.7.128.7 tun0 98-159-244-185.agas1a-dynamic.dsl.sentex.ca That makes sense: ppp send bogus request to the routing socket and the request has not RTF_HOST flag nor RTA_NETMASK address. It seems, earlier kernel code masked this bug somehow but it does not now. Anyway, we have two bugs here: ppp sending bad request and kernel having no enough checks for this somehow. Fixing ppp part would be easy. Please try this patch: --- usr.sbin/ppp/route.c.orig 2017-02-15 13:06:48.606161000 +0700 +++ usr.sbin/ppp/route.c 2017-10-27 05:14:44.006142000 +0700 @@ -801,8 +801,10 @@ rt_Set(struct bundle *bundle, int cmd, c if (!ncprange_ishost(dst)) { cp += memcpy_roundup(cp, &samask, samask.ss_len); rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; } + else + rtmes.m_rtm.rtm_flags |= RTF_HOST; nb = cp - (char *)&rtmes; rtmes.m_rtm.rtm_msglen = nb; wb = ID0write(s, &rtmes, nb); @@ -905,8 +907,10 @@ rt_Update(struct bundle *bundle, const s if (mask) { rtmes.m_rtm.rtm_addrs |= RTA_NETMASK; p += memcpy_roundup(p, mask, mask->sa_len); } + else + rtmes.m_rtm.rtm_flags |= RTF_HOST; if (ifa && ifp && ifp->sa_family == AF_LINK) { rtmes.m_rtm.rtm_addrs |= RTA_IFP; p += memcpy_roundup(p, ifp, ifp->sa_len);