From owner-svn-src-all@FreeBSD.ORG Fri May 25 07:46:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5C91106564A; Fri, 25 May 2012 07:46:24 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 975C08FC0C; Fri, 25 May 2012 07:46:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4P7kOtJ088667; Fri, 25 May 2012 07:46:24 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4P7kODU088665; Fri, 25 May 2012 07:46:24 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201205250746.q4P7kODU088665@svn.freebsd.org> From: Gleb Smirnoff Date: Fri, 25 May 2012 07:46:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235979 - head/sys/netgraph X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 25 May 2012 07:46:24 -0000 Author: glebius Date: Fri May 25 07:46:24 2012 New Revision: 235979 URL: http://svn.freebsd.org/changeset/base/235979 Log: Revert my local not yet properly tested changes, that leaked in with r235923. Modified: head/sys/netgraph/ng_mppc.c Modified: head/sys/netgraph/ng_mppc.c ============================================================================== --- head/sys/netgraph/ng_mppc.c Fri May 25 07:32:26 2012 (r235978) +++ head/sys/netgraph/ng_mppc.c Fri May 25 07:46:24 2012 (r235979) @@ -98,6 +98,15 @@ static MALLOC_DEFINE(M_NETGRAPH_MPPC, "n /* Key length */ #define KEYLEN(b) (((b) & MPPE_128) ? 16 : 8) +/* + * When packets are lost with MPPE, we may have to re-key arbitrarily + * many times to 'catch up' to the new jumped-ahead sequence number. + * Since this can be expensive, we pose a limit on how many re-keyings + * we will do at one time to avoid a possible D.O.S. vulnerability. + * This should instead be a configurable parameter. + */ +#define MPPE_MAX_REKEY 1000 + /* MPPC packet header bits */ #define MPPC_FLAG_FLUSHED 0x8000 /* xmitter reset state */ #define MPPC_FLAG_RESTART 0x4000 /* compress history restart */ @@ -632,22 +641,20 @@ ng_mppc_decompress(node_p node, struct m #endif #ifdef NETGRAPH_MPPC_ENCRYPTION if ((d->cfg.bits & MPPE_BITS) != 0) { - u_int rekey; - - /* How many times are we going to have to re-key? */ - rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ? - numLost : (numLost / (MPPE_UPDATE_MASK + 1)); - if (rekey > 1000) - log(LOG_ERR, "%s: %d packets dropped, " - "node [%x]\n", __func__, numLost, - node->nd_ID); - - /* - * When packets are lost or re-ordered with MPPE, - * we may have to re-key up to 0xfff times to 'catch - * up' to the new jumped-ahead sequence number. Yep, - * this is heavy, but what else can we do? - */ + u_int rekey; + + /* How many times are we going to have to re-key? */ + rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ? + numLost : (numLost / (MPPE_UPDATE_MASK + 1)); + if (rekey > MPPE_MAX_REKEY) { + log(LOG_ERR, "%s: too many (%d) packets" + " dropped, disabling node %p!", + __func__, numLost, node); + priv->recv.cfg.enable = 0; + goto failed; + } + + /* Re-key as necessary to catch up to peer */ while (d->cc != cc) { if ((d->cfg.bits & MPPE_STATELESS) != 0 || (d->cc & MPPE_UPDATE_MASK)