From nobody Thu Apr 07 13:14:33 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 266C71A8183E; Thu, 7 Apr 2022 13:14:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KZ20V0JfGz3qsV; Thu, 7 Apr 2022 13:14:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649337274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Wgqx3KeLTIEPyhtYQeWafacAal67vgo0RJPcsNoKyI=; b=TmfiLtyG/FRoMQAXxrgQSSbUR13wLG0WrKsd+eia197y/+AM8V8KRkeATYqgPF844nKMi8 ++ihNeJLBUacR/TxSmWuFWz6/HieXA8zSZXeXpRUsW4HKJI9fd6799StKW678oGF2gReH/ 2epYJP+7lP7zkj1dJJBJUywUG4dxFgLb/y6SkYRFqO6FQGRlw7jI4AF4zlITZnbbYBsBP2 o2vU/JNfhx8WOSazVXhJt7uOaplPDcdAd680sF/xxLCd+CxiM7PQEl3mA1C4eRsjuFOGxN 7WU7/eHAGyBfzkS9l7gQV590SMvUG19mKm+YdoykQAQvKB6KGi86sLQviQPFxA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D44FB10AAE; Thu, 7 Apr 2022 13:14:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 237DEXBm004477; Thu, 7 Apr 2022 13:14:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 237DEXJt004476; Thu, 7 Apr 2022 13:14:33 GMT (envelope-from git) Date: Thu, 7 Apr 2022 13:14:33 GMT Message-Id: <202204071314.237DEXJt004476@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 528d5d75e955 - stable/13 - Address issue pointed out in CVE-2020-25705 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 528d5d75e9557ee8e9fbfee68d15d4e1045cef3d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649337274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Wgqx3KeLTIEPyhtYQeWafacAal67vgo0RJPcsNoKyI=; b=n/XRXrn8a6BlaLfDiGJa3x1KdsnrQyyM4jUYD8ZgRxMe2r24Y/2bPW2kbnCFgatyfdrOy6 U+EoS2xuuQ38D/U5WKmLDJQPtTYh4dvFj9R9jtvZ4b6fmbx1Pf29804ztu+Ku5y3D7ZSt+ Ck95b5ZuWxh0uAt7Xdr5sM/lgMtE/CI4pC7l/Nz46sEJlEZDhYCnMun5tt5kaK/LU4D3B4 OUSe/zSo04uEQv+NpATRvnECX9EeLg/alQyAFPf/XABky1Yi6YSgOrmlOgvfdxo2apyaJj bAFB5I9ww6EOXbuJEZv+hnM1iJDF2IhRCpCmgpkRyctb6WfbzN7WMW5ovdS3iQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649337274; a=rsa-sha256; cv=none; b=aIKFUGh8wr+RShSwVYHowZsViDtsZz+XMmBEaOUYhRIo6w/aURgEMN5tbW9Iy45Iy6eYRY 3x5tNfKcwvCguDCvvEdXXTmbm9YYc1WioBa7/RmlRSwpeQyLcgJMAC2dRxpYlPwWfg0yde 95OhdQAFACCZNRxxavP5nNuZtDKUaoGCTBxLBPm6cv3v7EblDmeUUFrOpA7vsPy44vDVa/ kWbDyMXiNs7gJ7lArz7bENAmn2lEnxgbPJm8I6y8J6T0sfcC3tmFw4xsDfYWKxygsZ3KQ+ PAT1i5HyaJ+VbDXNmFwSlULd//yfpXGR9nj2zUyks7plMxyUV9qdFPeVMmmOCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=528d5d75e9557ee8e9fbfee68d15d4e1045cef3d commit 528d5d75e9557ee8e9fbfee68d15d4e1045cef3d Author: George V. Neville-Neil AuthorDate: 2022-03-19 16:48:16 +0000 Commit: Kristof Provost CommitDate: 2022-04-07 07:35:36 +0000 Address issue pointed out in CVE-2020-25705 Add jitter to the ICMP bandwidth limit to deny a side-channel port scan. Reviewed by: kp, philip, cy, emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D27354 (cherry picked from commit ca4cd20c4afeb68ae30c4cc1103280590a099fe7) --- sys/netinet/ip_icmp.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index f8dfc21df8f3..505e9a90300e 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -89,6 +89,14 @@ SYSCTL_INT(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(icmplim), 0, "Maximum number of ICMP responses per second"); +VNET_DEFINE_STATIC(int, icmplim_curr_jitter) = 0; +#define V_icmplim_curr_jitter VNET(icmplim_curr_jitter) +VNET_DEFINE_STATIC(int, icmplim_jitter) = 16; +#define V_icmplim_jitter VNET(icmplim_jitter) +SYSCTL_INT(_net_inet_icmp, OID_AUTO, icmplim_jitter, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(icmplim_jitter), 0, + "Random icmplim jitter adjustment limit"); + VNET_DEFINE_STATIC(int, icmplim_output) = 1; #define V_icmplim_output VNET(icmplim_output) SYSCTL_INT(_net_inet_icmp, OID_AUTO, icmplim_output, CTLFLAG_VNET | CTLFLAG_RW, @@ -1127,11 +1135,29 @@ badport_bandlim(int which) KASSERT(which >= 0 && which < BANDLIM_MAX, ("%s: which %d", __func__, which)); - pps = counter_ratecheck(&V_icmp_rates[which].cr, V_icmplim); + if ((V_icmplim + V_icmplim_curr_jitter) <= 0) + V_icmplim_curr_jitter = -V_icmplim + 1; + + pps = counter_ratecheck(&V_icmp_rates[which].cr, V_icmplim + + V_icmplim_curr_jitter); + if (pps > 0) { + /* + * Adjust limit +/- to jitter the measurement to deny a + * side-channel port scan as in CVE-2020-25705 + */ + if (V_icmplim_jitter > 0) { + int32_t inc = + arc4random_uniform(V_icmplim_jitter * 2 +1) + - V_icmplim_jitter; + + V_icmplim_curr_jitter = inc; + } + } if (pps == -1) return (-1); if (pps > 0 && V_icmplim_output) log(LOG_NOTICE, "Limiting %s from %jd to %d packets/sec\n", - V_icmp_rates[which].descr, (intmax_t )pps, V_icmplim); + V_icmp_rates[which].descr, (intmax_t )pps, V_icmplim + + V_icmplim_curr_jitter); return (0); }