From nobody Fri Jan 20 17:59:15 2023 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 4Nz6h32GWYz2t8WN; Fri, 20 Jan 2023 17:59:15 +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 4Nz6h31nrsz4Ky8; Fri, 20 Jan 2023 17:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674237555; 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=0XuSXjl5B9cN+RUnZIfNx4FVkXjaYQzt9TfBp2KSBFg=; b=fIWbm6ETGExW9DCQbJ1GoWCpgicgBxYYF+MPfADc0Ors5IkkktpK+Y4ZeX0ZnjXu5i3XeV O4vs6Z9lrOv9cIkv0+fPBiucSj4pxUUlNEKPftYZvsH6r16TQVEBZnz+ic8lDpNAqODI4m 8jrkFiUxGgh4u2wmF2bNm/6CzFXbvnEBTom/BtKAcCn1/TxMyBlEpzypaspz/nzO8pnaT2 Yn8u05Ryum5cCcS2D5fI4CqMc4IRjwci3uNy/BV30n88DWrISw1znn9Co4f/5FsfLpQt1Q Faarr3EyxErK5bKY9p4Eddk8wuKM0mY3R8/cxB7lo0xryPswyWa2KB1JxQB50g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674237555; 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=0XuSXjl5B9cN+RUnZIfNx4FVkXjaYQzt9TfBp2KSBFg=; b=NiGgxHbMsNt4SqZjALmbRcQ+WN+/GjNIBJpraOUPxNY7fdzRIbIDt0PVZiAt+rBTLaBg9q 9ADBbPOEnLJDtNJ2s8DtZxPdSozKbeUgQSbTIVPA+/DgpepW1ak7QTaEZC5VyGj8cldE0w Bd6E5Q9lTIqcOxy7L/IyFfGb9DJfNZwH0EOfKu+wT/mh6I4iwFjJw/Bs1TkdnjHu9mbsAu RAVvdacbAGe8wZuBQnGNYzzz4UBHSHzOE0flu0yb4514giC5gC0xadm9xjJgbfjiyMYfnU tNjLCgXOwgjhNhBOI09+Frp9hd2rkUZnDbDnTlqinuQXDw+fY4YTrKJyhkKkbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674237555; a=rsa-sha256; cv=none; b=NyUsi3UyqgnZnEPEhfY1ghBKK5Q5Xq59MyAZqPD4XRTFcoawC2TsUi/yCTotCjMja/XcGC bzfMn5Cv4tTkEk6LrC6TTRso+qbEXZMu2MMz4E1ozie6AaWNo/+gxbALHCF7TnYEbT7FSA J4FOsbI8hDW2yGzvnkXkT3xLhArVbis7sxSrrOFlKgblDM8kO04ET7Dy/P2ci71xtnn/AI Cs3sjvFoL2bKiE5UfHQ7euT0wpXcHEqNI/oguHLM09SleqmAiUDAmvA/HQcVRV/hEZmpaK 6XDGAAHSSyry0ACyu0LZiv4dG2fZvxTrtTCsBRHwcV6JjUMsn+rvmObWKE5Mmw== 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 4Nz6h30rsWzfps; Fri, 20 Jan 2023 17:59:15 +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 30KHxFvo084671; Fri, 20 Jan 2023 17:59:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30KHxFAS084670; Fri, 20 Jan 2023 17:59:15 GMT (envelope-from git) Date: Fri, 20 Jan 2023 17:59:15 GMT Message-Id: <202301201759.30KHxFAS084670@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: bfe8e339eb77 - main - bhyve: Fix a global buffer overread in the PCI hda device model. 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: bfe8e339eb77910c2eb739b45aaa936148b33897 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bfe8e339eb77910c2eb739b45aaa936148b33897 commit bfe8e339eb77910c2eb739b45aaa936148b33897 Author: John Baldwin AuthorDate: 2023-01-20 17:57:45 +0000 Commit: John Baldwin CommitDate: 2023-01-20 17:57:45 +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 --- 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);