From nobody Thu Jan 26 22:35:09 2023 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 4P2wWf31xyz3cCTF; Thu, 26 Jan 2023 22:35:10 +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 4P2wWf0dc2z4F44; Thu, 26 Jan 2023 22:35:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674772510; 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=XYafuQTrKTx2tWNJjo7LJY9dJcdi28ScUqyo6QhRb4I=; b=JOalj4nmKfPyrrCSvrF2zQ4y1Nzf32I+8D555v1+GFZWvUXFuBYADalnIR4Q2m3yJt+W3G iiY4P6LJN8LhaQP3wGLRfPIAtiRKHlNvTsDC52goptH4DrkcpHan9DNMOo9bVWp8bOfxb9 /CPj7bQetelOsU11+/eCN1qyPlGT5PQE/RCccTFhJ5aOT+LTBRamFNfQaNGMCU6ZThssjL e3K3BE6JhCF4pe9sJF5gj1wEF6buv4BRboi+APoVEdgsCj3YDH7KcxeDxwn9LGXaRO81yr b8+8isz13kgeAyS0CeguL0xLwQkNhf1JVykvuPRdhBxjzFPpq1VdJHivTS8EBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674772510; 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=XYafuQTrKTx2tWNJjo7LJY9dJcdi28ScUqyo6QhRb4I=; b=DgxbXZUai95z/wkxL1WlnGKyGqHvZVijnOyBE+rl7y6gzsHjm/9n6h50SoNQF/f2n5pHOW wE4Tza9qWjOY106PBy7Cwx6FE10b7dkaHPTWSwx2EasXOdiw3MbbY0BdJGnR4VqJ75jZP6 GMj383LxqMKFO3DpvTgejUDLjkMotzrZxf9oEMs/xUpFm35AH5EWfA7XYlZklp3Txb0Fif Pd4uYMcW1V5af8o7UVgd5YogKNFWJU65RGupxdfL/YJC8DnY6NCcdZ46sN2DCQBf0Yy60x z3Baugky1ZqAbVz3h+W1Soxn3PZXCqYfUb++nncL9DN8rRcPATdARIzuuMQgVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674772510; a=rsa-sha256; cv=none; b=gZdCAGQiIjWJzZLgyHBtSvXZJuLM8MAgx6PvZpw5qypBWLod1QRIqF7hptGdw4ZFJ0XGyF iQ54vvqejkDOyqIXoGEk4Kn5oxpVZpwGoPHbhi1nGuWeulegvBDkhwRa8gPJ46eFru4Rlx +IsgCouOcHLIa9B+NSuzqYuTuy14hzqLrIZnit4xZc/OfOdUw+LOygg59yGB67bwvcFVKO ixVSliQNc86hTfB4tQ+F2SeJAZllNJGer25avU5HbHb/5WbDXw3Q4yEImPVjXHvldWqcrK j3PddRITQ45sJDQAMo/aP/mKyfG1IITjxP8v1x/Ak0tu9Vct8KHtQzQ4z5gYGg== 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 4P2wWd6jDMzmK9; Thu, 26 Jan 2023 22:35:09 +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 30QMZ99c051755; Thu, 26 Jan 2023 22:35:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30QMZ9qq051754; Thu, 26 Jan 2023 22:35:09 GMT (envelope-from git) Date: Thu, 26 Jan 2023 22:35:09 GMT Message-Id: <202301262235.30QMZ9qq051754@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: f31dc54deed4 - stable/13 - bhyve: Fix a global buffer overread in the PCI hda device model. 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: f31dc54deed4bfc2779a991758033c36a9bf6fd1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f31dc54deed4bfc2779a991758033c36a9bf6fd1 commit f31dc54deed4bfc2779a991758033c36a9bf6fd1 Author: John Baldwin AuthorDate: 2023-01-20 17:57:45 +0000 Commit: John Baldwin CommitDate: 2023-01-26 22:28:56 +0000 bhyve: Fix a global buffer overread in the PCI hda device model. hda_write did not validate the relative register offset before using it as an index into the hda_set_reg_table array to lookup a function pointer to execute after updating the register's value. PR: 264435 Reported by: Robert Morris Reviewed by: corvink, markj, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38127 (cherry picked from commit bfe8e339eb77910c2eb739b45aaa936148b33897) --- usr.sbin/bhyve/pci_hda.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/usr.sbin/bhyve/pci_hda.c b/usr.sbin/bhyve/pci_hda.c index 9b0d4bd02ba0..bb8fba1a54bb 100644 --- a/usr.sbin/bhyve/pci_hda.c +++ b/usr.sbin/bhyve/pci_hda.c @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include "pci_hda.h" @@ -51,8 +52,6 @@ __FBSDID("$FreeBSD$"); #define HDA_CODEC_MAX 0x0f #define HDA_LAST_OFFSET \ (0x2084 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20)) -#define HDA_SET_REG_TABLE_SZ \ - (0x80 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20)) #define HDA_CORB_ENTRY_LEN 0x04 #define HDA_RIRB_ENTRY_LEN 0x08 #define HDA_BDL_ENTRY_LEN 0x10 @@ -246,8 +245,6 @@ static const hda_set_reg_handler hda_set_reg_table[] = { HDAC_OSTREAM(1, HDA_ISS_NO, HDA_OSS_NO) HDAC_OSTREAM(2, HDA_ISS_NO, HDA_OSS_NO) HDAC_OSTREAM(3, HDA_ISS_NO, HDA_OSS_NO) - - [HDA_SET_REG_TABLE_SZ] = NULL, }; static const uint16_t hda_corb_sizes[] = { @@ -714,7 +711,10 @@ hda_write(struct hda_softc *sc, uint32_t offset, uint8_t size, uint32_t value) uint32_t old = hda_get_reg_by_offset(sc, offset); uint32_t masks[] = {0x00000000, 0x000000ff, 0x0000ffff, 0x00ffffff, 0xffffffff}; - hda_set_reg_handler set_reg_handler = hda_set_reg_table[offset]; + hda_set_reg_handler set_reg_handler = NULL; + + if (offset < nitems(hda_set_reg_table)) + set_reg_handler = hda_set_reg_table[offset]; hda_set_field_by_offset(sc, offset, masks[size], value);