From nobody Wed Sep 04 20:29:46 2024 X-Original-To: dev-commits-src-branches@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 4WzYy24vVxz5VKZ9; Wed, 04 Sep 2024 20:29:46 +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 4WzYy21xDpz4JLV; Wed, 4 Sep 2024 20:29:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725481786; 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=WkToUt0t76w1eqLpMfpf7sPzG/Dm8hwgI9EImfeO5/0=; b=MbfnP0vZAxvA+AJvoBFPhgEXv1LIFN2Zp1nVZzXfbh4+MRIvGlnKVzVVHXEF5vj/0zjyu4 uYjrG9TXiMJcEFYllnAjPSD7xNORjDVPXzA9UAGlIl085TOvw+wAYAjC5I2JHP91AwDsQB gFan7u2oOKjMv8nPsPZ/uAyn4qSRuIlOT6jhLF2F/bvb2WixGMxD1JwwsRFl8KKLYJjmtI vhyCpIomfD/8NWzpVgwSkiwXG0tQXOfYNOHNhYATCC6BAelQ3JuDhvMkJ6NmvHfj10HOr1 h7Wj73mIoXKmTuIEGiR40D8KUjIb6mqYTroPTpjIwao2Qr9xpDLuhnXPEppShA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725481786; a=rsa-sha256; cv=none; b=YOsOdcPplXwwwmaVagfJ0T9pD4HodwY6MfoLxKKZJyvLG2Guc3Qnx1X4VH8l/ZhAo9p6aO 30Mxlfep0DETTH89bpR3I4XkWDILwfkzEPqPpcvPoeOucpS48f1bq0CrLRmubWaV2A40LH qrQbZhO/H5oAmBnqO1NcBoTMxR9U9zlI/2dI+iLZNyTMcGCEdSo89gg8NOEjiNjpN4mQj7 +KRooRFEuMMQ3q7HkdBmRoeBSqWtsaucQvx6BtPLJYx3BlU8ErqwM8+TJsRivyREqRgQPj apyLrtdwmsROuVQQ+DW2R47LzGkDfA75ZGnEXBpqkhqF73WVBaNncIJ0sgbNjg== 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=1725481786; 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=WkToUt0t76w1eqLpMfpf7sPzG/Dm8hwgI9EImfeO5/0=; b=s4pHBciLBRKd12jIWTQ5V6CdSi9+Cas+46W6s65Ei4OtEG7ZXmZnp67gBNyQaASLvz6+nE Wah3r1xTfvOHdK1/+Vnl7f4gMkJxnXvf8m1Ms/4hVwTL1P3vp/9AUgW44ebJhQO2EKSj5S 88MhZV1wPf/nSx3WBVnm4LTa/haLegwkZoSzVGLK4R+NYUoAZVS7rqwykYBOMVQMeXiEvD IprAMhdAIpnKNimIhZfdGouhDcD6C5wBneAsR5wtuBiKWBNv2ZknMSAMDRYZJiW1vyGq2A BZGh/oMMAtJ8PS10I0do+22G1NA7cBeuZ92VLLdZWIjCyIyiJePNQJSHSHXOnw== 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 4WzYy21VypzdyG; Wed, 4 Sep 2024 20:29:46 +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 484KTkLb082744; Wed, 4 Sep 2024 20:29:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KTk8U082741; Wed, 4 Sep 2024 20:29:46 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:29:46 GMT Message-Id: <202409042029.484KTk8U082741@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: 5d6576f4f000 - releng/13.3 - bhyve: fix off by one error in pci_xhci List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/13.3 X-Git-Reftype: branch X-Git-Commit: 5d6576f4f000104802c018a77ca119357f9bcc6b Auto-Submitted: auto-generated The branch releng/13.3 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=5d6576f4f000104802c018a77ca119357f9bcc6b commit 5d6576f4f000104802c018a77ca119357f9bcc6b Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:11 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:29:24 +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) (cherry picked from commit 5920b7e6eea1e1c46b78656ef75944fc0709e887) 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 58f2d53eb9b5..93161affd732 100644 --- a/usr.sbin/bhyve/pci_xhci.c +++ b/usr.sbin/bhyve/pci_xhci.c @@ -659,7 +659,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 & @@ -1201,7 +1201,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) +