From nobody Wed Sep 04 21:07:32 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 4WzZnd0wM3z5VP0P; Wed, 04 Sep 2024 21:07:33 +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 4WzZnc4KpWz4VlC; Wed, 4 Sep 2024 21:07:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725484052; 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=Gdwvn2/VaSNchUIeWbMja+/6yhEzaAHckRocFMwur9E=; b=v0mUSFkYigvCHgUB+6WZ2RG+09iwfz42VSZfqpHNQVTArxBS4wlM8Khi8kaA/iv6tLSgDu ACojsY0Luwk6IYAx8LVYCryrZLes47wU4P4GUD+QEdkzzNOISRjXhHuEtTYx2Z1DrLHP8K HFeqi4/DsiOEGr7dKmn25yE1A63skINYmM49wf4Aagir1J+B3UR4EoI+ofMST1oRiHlRdG We+dSnomeVB4cCtOdvczu/UzpsBKSzhAL6STtDxble4BkTyIEe1k7NLWApfwg1gg3+xwj6 nulQaUdEqEsICJTGzkziOOrWtctCRMoKqLaH8FsyzWC2qaE/yKPQETQnmVq6JA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725484052; a=rsa-sha256; cv=none; b=NUposMYSWmGvmyIOkJOne9V9UjMmO3JBCsi/Ao9l05LquxlJ/uSxJ95uZeu8vRDuJEVU27 x4QXCbVohyT4oillDnGPRPzYmGrxFQNFAY0CLrTwyEx4rPJrMMsiU0pPpeR42YG3+qwQm/ zkO31wkJeT61lN9H7442rBFbL60rrWrXQhdUVehrfkOQftz6r0EFrBufY3MdMNmShVbpSd 4Dew7pYT7tQSlUoJ574xT0/m4BS1ZtK2wfHTpr4xCXZiT1GSy3eR/diGPrA0IPHV1r2oAu s9i65OB7Nhp/7XunT0mpUybEu9bWOooYIqRpW2DG1ohhbg74wGoNCeQOh4Q8Mw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725484052; 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=Gdwvn2/VaSNchUIeWbMja+/6yhEzaAHckRocFMwur9E=; b=JJUbZ7IdCY4PGMpgtFoseRbu7xrWV2mj8sBcAqubzxl2KpVfS7+YakIYDm4hzu3/gAZcoH fPLi2VAzDiJh8xvWvC6PFb+KtKgm+OPUYPbJlXpLEJlvjrqSK7tXw7W+/cQf09RFHY/6Vu tIPlER7kVjOvb7lqtcLnUfzQXYMyDR1vfC8TxxyzFC1wAwKMSyehXu9Hb7jt2VbwdupHF8 QOxrzD6lZxG+EwXrNG7cXAtYvooj3k0wtnBJnPHVHdCUjPtUWZsT45Xl3FM87jiD54Uo/h NuosIDU4jVuYEzb4J/HETTbGsh9r1YSBHf5SX93NkIbLv1/dGhuoG7E/hArVYA== 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 4WzZnc2hLqzgcV; Wed, 4 Sep 2024 21:07:32 +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 484L7WLj053288; Wed, 4 Sep 2024 21:07:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484L7W1F053285; Wed, 4 Sep 2024 21:07:32 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:07:32 GMT Message-Id: <202409042107.484L7W1F053285@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: 1c872882803a - releng/14.1 - ctl: fix Out-Of-Bounds access in ctl_report_supported_opcodes 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: 1c872882803ad215e2c4bf867885d70e40f6f7f5 Auto-Submitted: auto-generated The branch releng/14.1 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1c872882803ad215e2c4bf867885d70e40f6f7f5 commit 1c872882803ad215e2c4bf867885d70e40f6f7f5 Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:12 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:46:54 +0000 ctl: fix Out-Of-Bounds access in ctl_report_supported_opcodes This vulnerability is directly accessible to a guest VM through the pci_virtio_scsi bhyve device. In the function ctl_report_supported_opcodes() accessible from the VM, the option RSO_OPTIONS_OC_ASA does not check the requested service_action value before accessing &ctl_cmd_table[]. Reported by: Synacktiv Reviewed by: asomers Security: FreeBSD-SA-24:11.ctl Security: CVE-2024-42416 Security: HYP-06 Sponsored by: The Alpha-Omega Project Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46027 (cherry picked from commit af438acbfde3d25dbdc82b2b3d72380f0191e9d9) (cherry picked from commit 803e0c2ab29bb6b715c38e82da4930d46590e8e0) Approved by: so --- sys/cam/ctl/ctl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index 9752ca93d36c..ede6b7d88b94 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -7514,20 +7514,19 @@ ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) case RSO_OPTIONS_OC_SA: if ((ctl_cmd_table[opcode].flags & CTL_CMD_FLAG_SA5) == 0 || service_action >= 32) { - ctl_set_invalid_field(/*ctsio*/ ctsio, - /*sks_valid*/ 1, - /*command*/ 1, - /*field*/ 2, - /*bit_valid*/ 1, - /*bit*/ 2); - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); + goto invalid; } - /* FALLTHROUGH */ + total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; + break; case RSO_OPTIONS_OC_ASA: + if ((ctl_cmd_table[opcode].flags & CTL_CMD_FLAG_SA5) != 0 && + service_action >= 32) { + goto invalid; + } total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; break; default: +invalid: ctl_set_invalid_field(/*ctsio*/ ctsio, /*sks_valid*/ 1, /*command*/ 1,