From nobody Wed Sep 04 20:54:19 2024 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 4WzZVM4w8Cz5VMtp; Wed, 04 Sep 2024 20:54:19 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WzZVM2LSjz4QHB; Wed, 4 Sep 2024 20:54:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725483259; 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=ocLGRFrQZssRbMgHx1wOodltFUvNxmKmDGcdavFjaXk=; b=WXnZFqdXO36uI71znzlAbIx74RLoGOyrkIAo0LSzEiPteJjKVWDtd/l7/IwRstGd2ppvjT iBdU5JbJ24zrxeWhiGdsO3YmXpEW1PvYli+uBvc6cPkx7k9kVgx9t4KcCgHaKu56oBJbsK vUYCJWjJqV1MIQtQ4Nkyb9pB01rqptNfdKajV4MzknQDDfNwB90svI9h5xwOW7iO9Q3rzT oLEhweHpM46iJcDs7mAN/BgMVjdDeR6Hokmev3UZMuaDmUjEKCtbC5uGaVghcLgR6PWO2A WhzKItRdD4nJZW4SmV3mFjwPuKtBecJ8F6u8RHr3z2G9rB5MITgqEJ5BT36Tgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725483259; a=rsa-sha256; cv=none; b=ZdRaMpxjheRo/KC9AitT5enJKxtYVqclslbyxoIzJrjfQL2Z2o+VyJD431tRK3oigAusZB ucCAnydW2mdLAAdWxYD+dwNy9gsRhaF+nG7TWecU3HDzKnqFVdDfa8yDByOm/W/c+uc9Om WvAil+rwXKDkOKH3g+cRAN0mfSfRHvK2Ow0+Ze+8DKN8CImRkzy4lQ3qQmQ6hYm4dPOJLv QO/mZ2ll0iC/bnIxTfAIaCCosPEO7O/Xh/rv0RxEylHnC4WDO/+iBnrxSsAjOYTiaYTl2h 2+/lAiOpOWhJrUIAFx49j2eNdxuMzny1gjbC8nOUNvQkfO4pkRDUgALRmWHQww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725483259; 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=ocLGRFrQZssRbMgHx1wOodltFUvNxmKmDGcdavFjaXk=; b=CYfr/DM9gp3QoW15ZWo8Et3nLEF4ObQC6NDMAXqHzS40gkq+lQo9XEfwQjKUn5GSRPxkD4 d8bSTXACrpkM3mRVOSQ83Xpp456pGPARU0SqiD6/bX3sfD/bxeeeKcIkQRF/ekqzwmpvEq PlcptvwRArPj38Ls3d3cVDTu7bU1rh7se8pRzczkGypeHCZb9U3optXeYGNtptymgQEKXT 0lLA6VN0vqDenODj/njF3tOXUq/agcFcy4Til8bpJlAFSPXFV5d8XyoX+DPnGDzqBHXyZO v2MFtUNQmCdQXfogKAJuam/dGPqnVtXcetavvnA4R88djPJzkoaneUJnbddCUw== 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 4WzZVM1xj4zfjH; Wed, 4 Sep 2024 20:54:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 484KsJY8033980; Wed, 4 Sep 2024 20:54:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KsJiO033977; Wed, 4 Sep 2024 20:54:19 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:54:19 GMT Message-Id: <202409042054.484KsJiO033977@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 1d01a6c11210 - releng/14.0 - bhyve: fix off by one error in pci_xhci 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.0 X-Git-Reftype: branch X-Git-Commit: 1d01a6c112104449c75b4da564e080021554030d Auto-Submitted: auto-generated The branch releng/14.0 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1d01a6c112104449c75b4da564e080021554030d commit 1d01a6c112104449c75b4da564e080021554030d Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:11 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:54:03 +0000 bhyve: fix off by one error in pci_xhci The function pci_xhci_find_stream validates that the streamid is valid but the bound check accepts up to ep_MaxPStreams included. The bug results in an out-of-bounds write on the heap with controlled data. Reported by: Synacktiv Reviewed by: jhb Security: FreeBSD-SA-24:12.bhyve Security: CVE-2024-32668 Security: HYP-04 Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45994 (cherry picked from commit 5c9308a4130858598c76f3ae6e3e3dfb41ccfe68) (cherry picked from commit 90af1336ed5e3c8556147325c4841c68639c4b63) Approved by: so --- usr.sbin/bhyve/pci_xhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/pci_xhci.c b/usr.sbin/bhyve/pci_xhci.c index 2d37cb0f08fc..3550dc1872ae 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -660,7 +660,7 @@ pci_xhci_init_ep(struct pci_xhci_dev_emu *dev, int epid) devep = &dev->eps[epid]; pstreams = XHCI_EPCTX_0_MAXP_STREAMS_GET(ep_ctx->dwEpCtx0); if (pstreams > 0) { - DPRINTF(("init_ep %d with pstreams %d", epid, pstreams)); + DPRINTF(("init_ep %d with pstreams %u", epid, pstreams)); assert(devep->ep_sctx_trbs == NULL); devep->ep_sctx = XHCI_GADDR(dev->xsc, ep_ctx->qwEpCtx2 & @@ -1202,7 +1202,7 @@ pci_xhci_find_stream(struct pci_xhci_softc *sc, struct xhci_endp_ctx *ep, } /* only support primary stream */ - if (streamid > devep->ep_MaxPStreams) + if (streamid >= devep->ep_MaxPStreams) return (XHCI_TRB_ERROR_STREAM_TYPE); sctx = (struct xhci_stream_ctx *)XHCI_GADDR(sc, ep->qwEpCtx2 & ~0xFUL) +