From owner-svn-src-all@freebsd.org Mon Oct 2 11:16:46 2017 Return-Path: Delivered-To: svn-src-all@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 9785AE3CC69; Mon, 2 Oct 2017 11:16:46 +0000 (UTC) (envelope-from julien.charbon@gmail.com) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3853363C98; Mon, 2 Oct 2017 11:16:45 +0000 (UTC) (envelope-from julien.charbon@gmail.com) Received: by mail-wm0-f41.google.com with SMTP id e195so6100084wma.5; Mon, 02 Oct 2017 04:16:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Sbuf7RpKkhvbLtr9tar9fFRZuafZYFm7dKgfgrnCfzc=; b=LBqPGbYn2ET066dveHE3xgqZLVQ0aa2bXzkMsTeXjUdbCuUeyuZoFxDtgKdenO07ZW h8Qbx12KvtAEaoju+eqtzO8uJBVGGyNZFw+WYSuiFySAOk7bvUYIx1CFAJ6S7GObNe/O vU1vcGRvCjjHQO1sxhubKJMZsIp519G7Dyif2OrdEwA3YNVtZI86Cc1wPoDNZ7QpMtlD 3jLFQkffFupybfkNWPu8ddaduOy+FucwLvQwLJWKo4MDrOzL9GifU60lFwLA+yPTssmS FtoukGUEGgAULFT43F2t8Q+TikMgvvfeu4M1mvlMoTLgjm9H+XoqIR1SMevEmKBr/Bez 5mlw== X-Gm-Message-State: AHPjjUiKKrsmLOMCtsuVF8nNhjEw9nAQSgfXAh4u3SB3e1LJNkG/+0fP WCKu6Ym2Fz477IjX2/oSh2357ybt X-Google-Smtp-Source: AOwi7QAOhbrpxb/QdvfODYoGiqNTJO2haWs8/raPR5usmVtErBIY7pRA2Flp7Pp5tkWQIli4FQl2HQ== X-Received: by 10.80.129.68 with SMTP id 62mr19784459edc.175.1506943003863; Mon, 02 Oct 2017 04:16:43 -0700 (PDT) Received: from [10.100.64.27] ([217.30.88.7]) by smtp.gmail.com with ESMTPSA id j62sm1084623edd.62.2017.10.02.04.16.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 04:16:43 -0700 (PDT) Subject: Re: svn commit: r324179 - head/sys/netinet To: gljennjohn@gmail.com Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201710012120.v91LKSH1050145@repo.freebsd.org> <20171002131218.3160093f@ernst.home> From: Julien Charbon Message-ID: <5c69c015-f3ae-954c-0f54-bf487eb6cab4@freebsd.org> Date: Mon, 2 Oct 2017 13:16:42 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171002131218.3160093f@ernst.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Oct 2017 11:16:46 -0000 On 10/2/17 1:12 PM, Gary Jennejohn wrote: > On Sun, 1 Oct 2017 21:20:28 +0000 (UTC) > Julien Charbon wrote: > >> Author: jch >> Date: Sun Oct 1 21:20:28 2017 >> New Revision: 324179 >> URL: https://svnweb.freebsd.org/changeset/base/324179 >> >> Log: >> Fix an infinite loop in tcp_tw_2msl_scan() when an INP_TIMEWAIT inp has >> been destroyed before its tcptw with INVARIANTS undefined. >> >> This is a symmetric change of r307551: >> >> A INP_TIMEWAIT inp should not be destroyed before its tcptw, and INVARIANTS >> will catch this case. If INVARIANTS is undefined it will emit a log(LOG_ERR) >> and avoid a hard to debug infinite loop in tcp_tw_2msl_scan(). >> >> Reported by: Ben Rubson, hselasky >> Submitted by: hselasky >> Tested by: Ben Rubson, jch >> MFC after: 1 week >> Sponsored by: Verisign, inc >> Differential Revision: https://reviews.freebsd.org/D12267 >> >> Modified: >> head/sys/netinet/tcp_timewait.c >> >> Modified: head/sys/netinet/tcp_timewait.c >> ============================================================================== >> --- head/sys/netinet/tcp_timewait.c Sun Oct 1 20:12:30 2017 (r324178) >> +++ head/sys/netinet/tcp_timewait.c Sun Oct 1 21:20:28 2017 (r324179) >> @@ -709,10 +709,29 @@ tcp_tw_2msl_scan(int reuse) >> INP_WLOCK(inp); >> tw = intotw(inp); >> if (in_pcbrele_wlocked(inp)) { >> - KASSERT(tw == NULL, ("%s: held last inp " >> - "reference but tw not NULL", __func__)); >> - INP_INFO_RUNLOCK(&V_tcbinfo); >> - continue; >> + if (__predict_true(tw == NULL)) { >> + INP_INFO_RUNLOCK(&V_tcbinfo); >> + continue; >> + } else { >> + /* This should not happen as in TIMEWAIT >> + * state the inp should not be destroyed >> + * before its tcptw. If INVARIANTS is >> + * defined panic. >> + */ >> +#ifdef INVARIANTS >> + panic("%s: Panic before an infinite " >> + "loop: INP_TIMEWAIT && (INP_FREED " >> + "|| inp last reference) && tw != " >> + "NULL", __func__); >> +#else >> + log(LOG_ERR, "%s: Avoid an infinite " >> + "loop: INP_TIMEWAIT && (INP_FREED " >> + "|| inp last reference) && tw != " >> + "NULL", __func__); >> +#endif >> + INP_INFO_RUNLOCK(&V_tcbinfo); >> + break; >> + } >> } >> >> if (tw == NULL) { >> > > This file needs to include sys/syslog.h, otherwise LOG_ERR is > not defined and the kernel build fails when INVARIANTS is not > defined in the kernel config file. You are correct and thanks for the report. I had sys/syslog.h already included as part of unrelated changes, then I forgot to push it: Fixed in r324193: https://svnweb.freebsd.org/base?view=revision&revision=324193 https://svnweb.freebsd.org/base/head/sys/netinet/tcp_timewait.c?r1=324193&r2=324192&pathrev=324193 -- Julien