From nobody Mon Nov 29 18:57:52 2021 X-Original-To: dev-commits-src-main@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 ECC3418ADFC8; Mon, 29 Nov 2021 18:57:52 +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 4J2vk84q9Dz3FdR; Mon, 29 Nov 2021 18:57:52 +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 86C7127C26; Mon, 29 Nov 2021 18:57:52 +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 1ATIvqAi020363; Mon, 29 Nov 2021 18:57:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1ATIvqKE020362; Mon, 29 Nov 2021 18:57:52 GMT (envelope-from git) Date: Mon, 29 Nov 2021 18:57:52 GMT Message-Id: <202111291857.1ATIvqKE020362@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d5ea04ee7ba6 - main - dummynet: Avoid an out-of-bounds read in do_config() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: d5ea04ee7ba6c7cd8e0918a080caf5f2c8fb3955 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638212272; 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=GqFUQQPyzN5OCSH0/Qm6sf93g60U6bdZudxb+4dtNNU=; b=ugvXeWAH9ip/M14g20jFBJeNkji50Sx+kTtscp/c7BtsF+YGK8+ao3pw/Xp33X1MyyUiLr 32NPW0w0Q0xQbIdtwqI8zb2esZYiInxi/MKtC9GB/PwaOXjggILr2dSHI6aTNrBjtRdUOy s02YIE47fPJa6Ub2ydPZhErClwF61bogJnBi+Rs4qYy1QHm4MkWrXpHTE9oGHQPLR/cTsJ 7KkaIKSOhj7a3AE0zRzbPWbX5WqQdHBFw1+6P+oj1rPdcfjVdTjB9hvAEUIeh8B8wdbdn7 0NnAg8ZQUPDds0/Bn6iAa93icCKH/+0ADhKCFWHqybQE/VgOG1/+Are6MGZj+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638212272; a=rsa-sha256; cv=none; b=ru4J9enzyP0tcZCoaQt8BRQWJAOLXGX6z4Tlwq9QJO128jGjCPenLjcwPXu8uLQ7YCqR/3 jVQg+0rJx1JzLLxFAYshQMeQC3p8W6oZJnVsHO68fpG0Kal1dp7XZi6287wXs8ebfXc95E +bhhRJv3X6h6TIO2dJMf8WQ6jAO1tbTNe3K4SCGjPmdyET+GMAonH6iGbmlhFvvcY/Sx7t RR1s02kvx2bhfT6HKuUo9L7IEHz5JBV924a5YkwmMW3ISWmbfQwdE2boXhdKSTv8fO8+a4 24sfQOooOETAJVidNhsE0DnhVqOyjNUxZ+yxIMj4rm8Ld/ylAKF4VFcA19fz4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d5ea04ee7ba6c7cd8e0918a080caf5f2c8fb3955 commit d5ea04ee7ba6c7cd8e0918a080caf5f2c8fb3955 Author: Mark Johnston AuthorDate: 2021-11-29 18:50:21 +0000 Commit: Mark Johnston CommitDate: 2021-11-29 18:57: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 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33132 --- 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 a890507f7b31..919445ff71d0 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;