From nobody Thu Jan 26 22:35:10 2023 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 4P2wWg3Fchz3cCdp; Thu, 26 Jan 2023 22:35:11 +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 4P2wWg1RSqz4Dyh; Thu, 26 Jan 2023 22:35:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674772511; 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=y81M9nMBZFEBeUHA/sBruBIh7N9JHMiqpL6jREYjCt8=; b=PPXW0IPa7dLeyEZqMmJa944ZGUXBR01K988gYWAlTidxRM0ukB1YkCRk8dj8JiyL0WcW4x KKUG9ut6WVSRzRetiwysptNIa9bm98skMooVjhusfsMg1aco02tZRicrmONatO3XPFIs0Z YafdyeMj+GSzCOjHlBSHU+FvN+uH3hSXF8zA8XHLKL4LFX3gfz6ooMGaq4RklheZ1foohO yNGK0Q9FVlbIS1FnTN6lS3UQo7dvUXFcim/j9J+Mu7FlIowX2kwXc2TEG70dfntjmdwWml uoZO071PNfxP+XRBAASJU2+76vNJqQ1IusFhemKma0eKj5C5TNIr4SNT1hENlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674772511; 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=y81M9nMBZFEBeUHA/sBruBIh7N9JHMiqpL6jREYjCt8=; b=bmDPPjdgHxHP/Kz5iY9OOCBYptGB+UTIs5CEkcvFey6c6efAMTbbdRpa2v8IHW8AdUdDu5 apmtZxbrZ9nKscj9Dsau1yKxOafnBkSPBs1uHzumwEkizijJBAI0umVmYDPgeZQUWGzqpk cOM4jcok2IQucH4JqQ6zFkZ3XRqKLp6Y7LTW7oeaqQVqmQF85+0KY6QHWa2uW7KbyVue2Q 7GB8KPxOEwlMix/FOmBiV8dKqKigIBnxUqOTxW3OlfUZyLsv3Dwjepuh1owCR//BX/rPMb 4takQKgDEWl0kFO3FUoOlKyi0zULR1Ux/JzfthRhxlKkhy1nIXRMB4HQIcCepA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674772511; a=rsa-sha256; cv=none; b=NphoNuK4UoBRVN7+2fiKevccn8qJIJvLaHnDL7L3iBK/PXR7EdisjZYMluJ1fXb3nG5qXu SC6aopkUhubOv2TnF51EdY0wtePc4BcOZRr2XvKF/XXne38VgYqEdG1LXuXH9NBNJet779 lSenRtGwyhCTGpXLNlTIoCv1et+8Yqp0XjiC32sDnDL7QC3GDLiVNtQKvSoNfaI87pDVib felW0GnKCCj7/6OFK3GZl5w/LulcELP8rtzFTlBcPqoLjt7GmeXgTUd+xHI78RbobJSAZ2 CEviJM23nphXTqqufwqgATNSPYjSRaQv44wbyq1kQ7am+RiCLNPWu6i9Uaq1Vg== 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 4P2wWg0VTnzm7x; Thu, 26 Jan 2023 22:35:11 +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 30QMZA7R051779; Thu, 26 Jan 2023 22:35:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QMZAvE051778; Thu, 26 Jan 2023 22:35:10 GMT (envelope-from git) Date: Thu, 26 Jan 2023 22:35:10 GMT Message-Id: <202301262235.30QMZAvE051778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: abdc47cd6969 - stable/13 - bhyve: Fix a buffer overread in the PCI hda device model. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: abdc47cd6969a649ee7b4bec0efe0d51bc95dfdb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=abdc47cd6969a649ee7b4bec0efe0d51bc95dfdb commit abdc47cd6969a649ee7b4bec0efe0d51bc95dfdb Author: John Baldwin AuthorDate: 2023-01-20 17:58:38 +0000 Commit: John Baldwin CommitDate: 2023-01-26 22:29:06 +0000 bhyve: Fix a buffer overread in the PCI hda device model. The sc->codecs array contains HDA_CODEC_MAX (15) entries. The guest-supplied cad field in the verb provided to hda_send_command is a 4-bit field that was used as an index into sc->codecs without any bounds checking. The highest value (15) would overflow the array. Other uses of sc->codecs in the device model used sc->codecs_no to determine which array indices have been initialized, so use a similar check to reject requests for uninitialized or invalid cad indices in hda_send_command. PR: 264582 Reported by: Robert Morris Reviewed by: corvink, markj, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38128 (cherry picked from commit cf57f20edcf9c75f0f9f1ac1c44729184970b9d9) --- usr.sbin/bhyve/pci_hda.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c index bb8fba1a54bb..9e9d7ab5a626 100644 --- a/usr.sbin/bhyve/pci_hda.c +++ b/usr.sbin/bhyve/pci_hda.c @@ -475,12 +475,14 @@ hda_send_command(struct hda_softc *sc, uint32_t verb) struct hda_codec_class *codec = NULL; uint8_t cad = (verb >> HDA_CMD_CAD_SHIFT) & 0x0f; - hci = sc->codecs[cad]; - if (!hci) + if (cad >= sc->codecs_no) return (-1); DPRINTF("cad: 0x%x verb: 0x%x", cad, verb); + hci = sc->codecs[cad]; + assert(hci); + codec = hci->codec; assert(codec);