From nobody Wed Sep 04 14:40:03 2024 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 4WzQBW3y8Gz5V1y6; Wed, 04 Sep 2024 14:40:03 +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 4WzQBW3Qt5z4F36; Wed, 4 Sep 2024 14:40:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725460803; 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=sHAzqgd2O5wvzTaSbM4XoEa/72bqcRRlCjB7juWowlc=; b=fVS4S1y3VpvMsfYH5pwQ7Or+WCROSmT774PwlCRV0zyOssspA5QJwI2R8blDMxwT9+TGrH UJoV532OMEY0kdCWQ83rGZQVcpCTN5vEYlvo3TMYVtxKs3Cf6jjM+Y/kcPUSIvfZZRxUzT D6+9n/y6z3aD2SpB3iQD1l66HWgBTVQBAyvwslYzJslA2e7RfPxvgoC/DHwZtAqu/EXSTe gK1JX0sNm3mx/hflDFX7MPSarc+dBLe4+3MSjxhB8XrMVWT1REv7HySqHXG+dcRWdaDNsA vzbcO1f5GjTXXI7Bl7fGikn2C2wXk5vqwyTlE0Eoi+Sc9Wa7BxOyyBFBvlrzXA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725460803; a=rsa-sha256; cv=none; b=GohmyQ8t+I1AKXOnnkdwOTgpxILBR19S4V4QYsra3nwp5K0fjq3xobbJs74No5VhO5B+Us GKFtYR5tZWqCzUeWMZkvMhPEsOU6hU5SM2n0DuAL8+YZa4b9oHUbAMmyMg7Cq0DDEpg8Wy UvKtUgOL83qVpm6PmyJ97dFdXCqm2otHckYEoaUTfEls+49GxPyddYcs2SYcKcywoVfodz eD6DPXJjtroD06BgPCpn9oGV80ighMNOeoh8NAo3rpQLwmZjwXjk89f0bmXHcBeQx02tHe 2HBtrvY/BjvzKP2QGLthZ9h3FlxlbjZ7E6sKrWCXE30vkX1Mk8Z2DdCALDclVg== 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=1725460803; 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=sHAzqgd2O5wvzTaSbM4XoEa/72bqcRRlCjB7juWowlc=; b=g+2pKl5TirppaWQiVKZyXtGB5s99fZaabtFxHA+XLnvblqDsMCaDAvom4eAp37y+hdyu51 c/nZ4BwJV3esKS5PnUZwdY1PAMLBPopVI9MBNfgngPbccWIBcELHDYArRpqsaCeswpeM/p sn+ZIKX4/wS02Q6vunrnsTCiFcv+5slr4oUkvsRaEGwLteu3wACuEkJ7YAw5iBF8fa4MGB VDdiJesPGMTzjC+1T5AcUDAFAaUkTWSbt4yyn4t1YPSl9KZ8+j0UgTnIFbKScVnAf3RPVv xlyfWrhNMK/MBQAcJAkQgJr7ADNl/+3G+KcWY8mWT6YmLSDWH27P4RboeT7LgQ== 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 4WzQBW2lGJzSqm; Wed, 4 Sep 2024 14:40:03 +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 484Ee3A0086506; Wed, 4 Sep 2024 14:40:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484Ee3Wq086501; Wed, 4 Sep 2024 14:40:03 GMT (envelope-from git) Date: Wed, 4 Sep 2024 14:40:03 GMT Message-Id: <202409041440.484Ee3Wq086501@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 5c9308a41308 - main - bhyve: fix off by one error in pci_xhci 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 5c9308a4130858598c76f3ae6e3e3dfb41ccfe68 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=5c9308a4130858598c76f3ae6e3e3dfb41ccfe68 commit 5c9308a4130858598c76f3ae6e3e3dfb41ccfe68 Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:11 +0000 Commit: Ed Maste CommitDate: 2024-09-04 14:38:11 +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 --- 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 8654dd9e7a14..b72c839c807b 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) +