From nobody Tue Oct 29 18:49:54 2024 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 4XdK7Q5Mcjz5bn9d; Tue, 29 Oct 2024 18:49:54 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XdK7Q3ZXrz43tB; Tue, 29 Oct 2024 18:49:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730227794; 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=uLl0he2ek8lyXqGcEZoEVgU9PLTekiTxjDylJ9Nl0zQ=; b=VIdlqWx9Ir85zjyDmtjiSNuH2zwIySH6UzdXKF+/QqU3Mnw3pzo33L+mosp8KMZ1p8dM5a ZwhZNkbsSQ/1IfLCZ/l4ZX344rvG4wi+gP1qMj0gd5MpJUnaNJPZNZqso2Inr/7FqEhdId ahWEx6Qvo70UyVxNC7Xz1s/T4F1aBpNPUYtzI/pgYG4Z2FsdSIyJmxEBRShaj0CIczDUBf fBBTOVoOevD4lgPC/JJ5X3JU173aZ0KjanAHy06ppmlh+CNG87v9MpVb9LIAoUbDpEXK5D IgNgtS0abliWtkHRsGEOC/In2BQ9UwNRwh1les6lHbV4Jr3fM/syAjTu7QUakw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730227794; 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=uLl0he2ek8lyXqGcEZoEVgU9PLTekiTxjDylJ9Nl0zQ=; b=vGFQprh0DHNYF5v0NPbrI9Mqwyt3DfQ/42JOmdBLJwOTaJHTftoPd3gENEkyHT0lH0f9K6 Rh4Vf5o39ozFbmYfv1k4DR4UPEVWOFVV3kuN2R46US7TNR5hcZ3wAqGaJp7Fgffsx+dsAF /sf1DPQ7NJYfDjlz6v5K6Umkik5ui89DDgGlJuaHibyNWRQDf6LTY893u4+4mu8Y41EPNH rm7flTG04LW7t8yHp0G5vF51NBNskCTpJy34whmPBQsd23EfT0IDziy0GBo6rGFL7nJZFA RUGTfDogPmVkIsewLGgQz0P7w5dNWqhLiljqlGJsD7jQlyIpC2QBTIUnAcZxkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730227794; a=rsa-sha256; cv=none; b=xKaxdea2bOF31jKM2olf/tsu4vrB2ir3MPCFcpkNUcJITnn60Le7Ybf1tfMHiBOafEyViN Nl8RwSa/bxgzAvQqj2MTiyWd0osBndxvYuDBOniOrbTByONWIGDnBSrNIs6UkFfpJZ8v4W HbFdspne07nwkwdRv0VnnGzxnZ1fdN43CT73cZ/U0QV+Urhzqyl9HWrV2J1ARAFewNgpAk CfYfY27L5MszOfDvTGKl9lW9UPypP5wE1dxgYIzYNgILjyOtMzww2xdhynS5n+qwBtWpAx QN5cNvb7aJmn+hKRDvWoroDJHJEV2ch2i5f/7u9pbHB2CCewlNg1+EkprfCWmA== 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 4XdK7Q2vZNzZwN; Tue, 29 Oct 2024 18:49:54 +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 49TInsN2018666; Tue, 29 Oct 2024 18:49:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49TInsBP018663; Tue, 29 Oct 2024 18:49:54 GMT (envelope-from git) Date: Tue, 29 Oct 2024 18:49:54 GMT Message-Id: <202410291849.49TInsBP018663@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: cfcbeed4c7d5 - releng/13.4 - bhyve: improve bounds checks in hda_codec 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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.4 X-Git-Reftype: branch X-Git-Commit: cfcbeed4c7d533fba817b38cf29e51206ea956ff Auto-Submitted: auto-generated The branch releng/13.4 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=cfcbeed4c7d533fba817b38cf29e51206ea956ff commit cfcbeed4c7d533fba817b38cf29e51206ea956ff Author: Pierre Pronchery AuthorDate: 2024-07-24 14:56:54 +0000 Commit: Ed Maste CommitDate: 2024-10-29 18:49:15 +0000 bhyve: improve bounds checks in hda_codec The function hda_codec_command is vulnerable to buffer over-read, the payload value is extracted from the command and used as an array index without any validation. Fortunately, the payload value is capped at 255, so the information disclosure is limited and only a small part of .rodata of bhyve binary can be disclosed. The risk is low because the leaked information is not sensitive. An attacker may be able to validate the version of the bhyve binary using this information disclosure (layout of .rodata information, ex: jmp_tables) before executing an exploit. Reported by: Synacktiv Reviewed by: christos, emaste Security: HYP-13 Security: FreeBSD-SA-24:17.bhyve Approved by: so Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46098 (cherry picked from commit e94a1d6a7f2eb932850e1db418bf34d5c6991ce8) (cherry picked from commit 757bbf484c0bab2c4c7b504017079cceb833f7ae) (cherry picked from commit 6cb1995a66aec98261256bc4da3eedfe840e1ab9) --- usr.sbin/bhyve/hda_codec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bhyve/hda_codec.c b/usr.sbin/bhyve/hda_codec.c index 1866149c020a..b7d6ec043675 100644 --- a/usr.sbin/bhyve/hda_codec.c +++ b/usr.sbin/bhyve/hda_codec.c @@ -521,7 +521,6 @@ hda_codec_command(struct hda_codec_inst *hci, uint32_t cmd_data) payload = cmd_data & 0xffff; } - assert(cad == hci->cad); assert(hci); hops = hci->hops; @@ -530,7 +529,10 @@ hda_codec_command(struct hda_codec_inst *hci, uint32_t cmd_data) sc = (struct hda_codec_softc *)hci->priv; assert(sc); - assert(nid < sc->no_nodes); + if (cad != hci->cad || nid >= sc->no_nodes) { + DPRINTF("Invalid command data"); + return (-1); + } if (!hops->response) { DPRINTF("The controller ops does not implement \ @@ -540,7 +542,8 @@ hda_codec_command(struct hda_codec_inst *hci, uint32_t cmd_data) switch (verb) { case HDA_CMD_VERB_GET_PARAMETER: - res = sc->get_parameters[nid][payload]; + if (payload < HDA_CODEC_PARAMS_COUNT) + res = sc->get_parameters[nid][payload]; break; case HDA_CMD_VERB_GET_CONN_LIST_ENTRY: res = sc->conn_list[nid][0];