From nobody Sun Oct 06 15:06:48 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 4XM5Gc5rB6z5Y9x4; Sun, 06 Oct 2024 15:06:48 +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 4XM5Gc3mvdz4BpG; Sun, 6 Oct 2024 15:06:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728227208; 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=4NTgafyVM5mYp15AcTV3u5pr2cdLaZn8aBb1OuIBkZ8=; b=kSdrbdDhePJVp5ptsuH052p8Txg4EDAJW4bBwnDx26StuVwppX0DG92tpRXZ5EC7ilPvSS 583Fl5BRdJeecMN4xryZpCpupDmEdSTVKHd0quX4xiisdtiM5KPhITjcofarsju4kA61Gk FSCfvUacMczHctuNR30fTf+nDZXtgdBDWgxxcqUsTUcVR1yAsUG9mcXp0ENlF1QdKxGKxQ wvBEbt9mwb+CQwseVaIPZez7nTcaPBbU8rVkMnc5Uu7okkd4+HMJsifuHn9jVXomLuHZe1 fdJVoh2XHZGdZfYXdDbFBOB+UicbJxy2T9JPZ2myWt2GSAJyDgT9mj772QUkBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728227208; 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=4NTgafyVM5mYp15AcTV3u5pr2cdLaZn8aBb1OuIBkZ8=; b=VzaP1JsX8/AcP9i6wMeqOeh1EYbGMDh4nYDfJOs0BGiBlgAkhMfVa+VmWjcT6NRbwSXb7D GuRWtcvSomo4kPDwMhXIF0vPx+pIbI92E1jsd2MO2iXajrBBiookk2sKg+V4qbLJukkzpZ CpWnXO0yZazovqLc2NuCdRErgxM9YAc0hBewueZDWdaKaikvdduq2fyBXAKmyle42ZV2Ne 087sd+G1Ot8qHQW4pyD+RQkf9/VNuQlm7f/F5RmT8/rjhBe4p1Ehab248xwiWhBfJA3hhM oK2i+DbLM+v5TFqrPtJUYXevOoYiFWSghPLP6dO0rKA+gb/XQN517+yxmK/DKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728227208; a=rsa-sha256; cv=none; b=A5iq8fGFts91TaWl8FF+J2AT3xS1qNPHIWrVYu5bgKgiCwnrjUg/YMd/cHQqUxMbn6QpzH N3k+r7/6qKDp4ZziwMx1J/PgYPXtdPT8DPJbeZejkvY2/mW9Puv73QR5jdvVwZL5uFE6dl 8AfgTgOKJTfafjf4djuKT0IKrT8Jaj7dagXpSIhCd8ZgjqrP8BowQPuJmZ+pDmKumhL/vp CoARCDZgHJEQzmcrqgUTTR0fSo5wCrvXri/uzHRWCdEn6jbhQV/j8/eCYaZHA1y1JRRDbh 7bwLPnzfc+ubzWBQsgHH3dhFfRAJoT9ofgmocGrM95M0OyGTnFghsiZAC31tTg== 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 4XM5Gc3KQZz15Yp; Sun, 6 Oct 2024 15:06:48 +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 496F6mgX049074; Sun, 6 Oct 2024 15:06:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 496F6mh6049071; Sun, 6 Oct 2024 15:06:48 GMT (envelope-from git) Date: Sun, 6 Oct 2024 15:06:48 GMT Message-Id: <202410061506.496F6mh6049071@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: 6cb1995a66ae - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 6cb1995a66aec98261256bc4da3eedfe840e1ab9 Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6cb1995a66aec98261256bc4da3eedfe840e1ab9 commit 6cb1995a66aec98261256bc4da3eedfe840e1ab9 Author: Pierre Pronchery AuthorDate: 2024-07-24 14:56:54 +0000 Commit: Ed Maste CommitDate: 2024-10-06 15:05:09 +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 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) --- 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];