From nobody Mon Dec 06 14:04:58 2021 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 A286B1893204; Mon, 6 Dec 2021 14:04:59 +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 4J74ty5lx7z3lx7; Mon, 6 Dec 2021 14:04:58 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 61B065128; Mon, 6 Dec 2021 14:04:58 +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 1B6E4wDL081798; Mon, 6 Dec 2021 14:04:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6E4wCo081797; Mon, 6 Dec 2021 14:04:58 GMT (envelope-from git) Date: Mon, 6 Dec 2021 14:04:58 GMT Message-Id: <202112061404.1B6E4wCo081797@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3f1756dabfe2 - stable/13 - dummynet: Avoid an out-of-bounds read in do_config() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f1756dabfe263c279c7dc29c54398d95f8b0988 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638799498; 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=L+LezzABUYFMXN1f15XqeakObqDgasxi2ryLGNfFEcM=; b=SrSEjIiVMshHg3YbKL4FvB4WUGFk25+hu6GgqphsKGZ7fEnEIhYQXhHj5XXf4rPjh+VRVn kPrnBuopjTOPFAppPD7s+0lac79+C9QL6BTROEXaD1DZeu2gvReI8LYE5ajA0beveDTvHu bzV9/bbxyWpg/J/hU3LuQkh14pWPOtRyTetgggkOS6NOX4Y7/WXt3apaOI/18zQ+B+C7ys JVIORQDCgDiijOVgjLw/0Z3zA0hKkbh+pCjBmihmakSzz/pb5/IwJ6uPbSYa3fhRiWdJh+ InPUtEpvN3ecMsb+wFWMu6Ni2k+/0HU6Xbz/PgSqnYOQOva3mYZMEpFesW+Duw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638799498; a=rsa-sha256; cv=none; b=YnVaAISImwqeOmG5AQDPHbzn9KImMO09JTIVV0tJr5PfBljhPqOlAVS6TSA61fjKSk7sJ6 iuDTdKoIzXzx6sTxJzKBjL5KQbqrC8UsMm/MuvazBDRQcZBPwI7X7ZxwLp0W+mcfTv66RZ nX6vdVmYqnAsJLXnGeHyz5QGV3VRef3ipx8WOi3AFvQ7aksZkBuW3YIeLjFk+FzX2kgPe2 rJEo/GWUKXocoxME4hJ1mVtNcOPjNrgaAwPZ9bHC2x+vUYw+tquX2nlltZwq7iRERqCUGe SgGlhx5axyIbPyANFPf+clJOGX1ZjMaRLowl1ZLqsrUQ/3ULpQdSJZocf3kvZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3f1756dabfe263c279c7dc29c54398d95f8b0988 commit 3f1756dabfe263c279c7dc29c54398d95f8b0988 Author: Mark Johnston AuthorDate: 2021-11-29 18:50:21 +0000 Commit: Mark Johnston CommitDate: 2021-12-06 14:04:19 +0000 dummynet: Avoid an out-of-bounds read in do_config() do_config() processes a buffer of variable-length dummynet commands. The loop which processes this buffer loads the fixed-length header before checking whether there are any bytes left to read, so it performs a 4-byte read past the end of the buffer before terminating. Restructure the loop to avoid this. Reported by: Jenkins (KASAN job) Reviewed by: kp Sponsored by: The FreeBSD Foundation (cherry picked from commit d5ea04ee7ba6c7cd8e0918a080caf5f2c8fb3955) --- sys/netpfil/ipfw/ip_dummynet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c index d3242fd85817..cee478a03274 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -2011,7 +2011,9 @@ do_config(void *p, int l) } arg = NULL; dn = NULL; - for (off = 0; l >= sizeof(o); memcpy(&o, (char *)p + off, sizeof(o))) { + off = 0; + while (l >= sizeof(o)) { + memcpy(&o, (char *)p + off, sizeof(o)); if (o.len < sizeof(o) || l < o.len) { D("bad len o.len %d len %d", o.len, l); err = EINVAL;