From nobody Mon Dec 06 14:18:41 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 B98B51896EBA; Mon, 6 Dec 2021 14:18:41 +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 4J75Bn34T8z3pHg; Mon, 6 Dec 2021 14:18:41 +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 4966651A6; Mon, 6 Dec 2021 14:18:41 +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 1B6EIfwu095622; Mon, 6 Dec 2021 14:18:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6EIfOZ095621; Mon, 6 Dec 2021 14:18:41 GMT (envelope-from git) Date: Mon, 6 Dec 2021 14:18:41 GMT Message-Id: <202112061418.1B6EIfOZ095621@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: 55351c2620c5 - stable/12 - 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/12 X-Git-Reftype: branch X-Git-Commit: 55351c2620c5c9387cacc47def0f8c0bcec237f0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638800321; 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=BaTFanZZoBbZFVqIzI/V35N4JyNwekyXzGeI1Wk51mc=; b=YpewYI37gL/VcJEUHY1yqifAMP+5WhhFBvws32NngxhlpE2x41RNzIcq64fMW3QGwTdat6 uGIrbfTSATuPShoMTxIvSfeL8c0OtuySUJcZ4cU3q1+osUGjhfQnCcSQXT8/ooF0tBOj5F 6EfCGXXXoN6w39vpd4a0nnn3Ty7ud6GVrmvPK/XjXHVP23NF2Q90oLKusTJq2Apsp5UJtB YZfp0cQIhkkzgae+8Nm51HDTgJZzsMgWdcJWRcmkDV6FUcMsoqMbPpFJiMlwt6LrGEbWs+ opjDPkBx+FJRrnL/DZl8sT4sGEeAEfCskvlQQe7TDdOjUUz0x6kcL7pk2+Y06w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638800321; a=rsa-sha256; cv=none; b=yeKvPoTAtRvgfWlKYDQAnA8a1zwvJhMAXsx4IcpP4mhcEzb/3L0jkJEcE82uXBE2NIoqW4 HjdHkme4ACYLlZ4M6ZIxlqBrXBNhJU4Jicrf3eW5sa7yeYRDYC2DitguRU6E1KKAHu6Wcv HDHON1jD7/Nu/iUJOuU9loB48UvxielVEmgv4kkyrgLObQWCGXbmfGCxWagu06PgNOjmBR V/+ltbm3/7O+iy0GScmQpPdI9sb/Ykt1/2ftjlMDSm8Vfl+DV4c4kuGIwNYA3l4IoADoRX aeCML17N+PdeYmeDPXfPQ2TCFgXBIKN3yeOaH78TkfKarf3pRPZphZpn8rTR7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=55351c2620c5c9387cacc47def0f8c0bcec237f0 commit 55351c2620c5c9387cacc47def0f8c0bcec237f0 Author: Mark Johnston AuthorDate: 2021-11-29 18:50:21 +0000 Commit: Mark Johnston CommitDate: 2021-12-06 14:18:24 +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 5a88a803e88d..57dbcb3c9a35 100644 --- a/sys/netpfil/ipfw/ip_dummynet.c +++ b/sys/netpfil/ipfw/ip_dummynet.c @@ -2012,7 +2012,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;