From nobody Tue Oct 29 18:45:35 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 4XdK2S04RTz5bmYp; Tue, 29 Oct 2024 18:45:36 +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 4XdK2R65Vpz41HP; Tue, 29 Oct 2024 18:45:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730227535; 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=ci2FS2veAmoHaCbURbgvXhaLGkf89XCrKpsQ4PCutUs=; b=wQ/OvG6b+zAGHEhbxureXEF/H85O9FLBuLJ7k+XCMioSGAKq9fgQuopEyT57ev2dV0L+8a 5Ey1HiERm+2Tq1BhMSHoD6eJ2Bgux+FKmz6ZTNY9AG5tgooMdvlrFxMCUthqyovxXjbEV1 bplKqWPUe7kxZ1EF39QhwJIQ9KsdjPBv6j5/hzMkvc7lNHAuC6E3/bvKYVxCaeSxPye2py 2apMPd9rJ3PB+XAxm+0CsDx/sbfi1sHeueLqPuqKf4xBT7K4lf8jfy+ZAz65YFOBjKgRWo 7QTM2xNdoPupmH+ZpLlVsXyxSJpSusQMV9P8GrmlQXRT/YudbXwlcAwJgxYAew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730227535; 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=ci2FS2veAmoHaCbURbgvXhaLGkf89XCrKpsQ4PCutUs=; b=oWxahbImNgUZLc8zNZmG6xzHt7Nkeno9P2mLQ2lbjZBql/RL4hLur6qMaPz413wiR2X4ox rNSjuYuZ3CmCCm1f9kmDvBpd/J9QtnSRgG9q2LUb4v2QEw6QPB1KPq6XYj3c3k78DMHHRi bhinP2UOsISCHz6xx5II8Vs6sLnzTiCiFGSJgEJNDL6WQkPX2Natte01SEI1DLaKGomIWs ioNyY+ZiLvOqfcV0RuTJy58wBGo1mHLZnmO5XCyhob32c4uCzzbY8ZpNX0M/TIKFpeT+y4 OXl+0G6wTK6ZE5Ys3qvccjLUGedsSlC8Usw/FvC7bF7GWyuwPOQNwnSQ1WTWgw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730227535; a=rsa-sha256; cv=none; b=IT2LVVMb/34xVuUAU8NiMr/qDCjLVuVqtSc41YBMdBF244EkaSienTYOR35O7BTVIatTht zMRkhRtWuRZ/P9yVVqD+2O8RqS0gKTnYd3+/4QBEWBNOCINRCjc47pv8hwfeeRCZdi7Q5C PKdoZe9ZnFnZfCRegEfxOtFdAOaZ3KbIRwvsldzIXVB7iCsx0B+FtC+0OotgRIqkaxjPai KKCCyjRXgieb0xI4CX9VVYmPACG9do0/osiF3rYLn2nMhwlp4dN2JlUXEUPg5vm8TBuJpe Jwo6tzFvAjOR+4zhNTdOt3gGiFcf8NEVnYSgNLWr39Gd/t3zWW7FpSWhog9tFg== 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 4XdK2R5QRlzb7D; Tue, 29 Oct 2024 18:45:35 +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 49TIjZ1g017017; Tue, 29 Oct 2024 18:45:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49TIjZxj017014; Tue, 29 Oct 2024 18:45:35 GMT (envelope-from git) Date: Tue, 29 Oct 2024 18:45:35 GMT Message-Id: <202410291845.49TIjZxj017014@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: 538cb37f512a - releng/14.1 - 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/14.1 X-Git-Reftype: branch X-Git-Commit: 538cb37f512aea39c9eacd8bd393bbad9f913e1f Auto-Submitted: auto-generated The branch releng/14.1 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=538cb37f512aea39c9eacd8bd393bbad9f913e1f commit 538cb37f512aea39c9eacd8bd393bbad9f913e1f Author: Pierre Pronchery AuthorDate: 2024-07-24 14:56:54 +0000 Commit: Ed Maste CommitDate: 2024-10-29 18:43:47 +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) --- 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];