From nobody Wed Sep 04 20:54:16 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 4WzZVK1rpZz5VMsG; Wed, 04 Sep 2024 20:54:17 +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 4WzZVK0cTPz4Q5X; Wed, 4 Sep 2024 20:54:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725483257; 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=VgsABGMfzIlRaotesFlPasoGAsfntzG69egjUcpYIzg=; b=ClN8TDq5bfDI74ltlz5XUH4gAhljXYQnxJYD+JwAVs9v9QqUN+0GrAEcCf7qCM6recZ0gY GcH7BgVC9dbfmlMAj1GsmIs4CEaVOf6w3wBbLyo8bSW5rdImvhPYaP7Gd/F9LkGeyQNVG9 XIrxPr4Ki/FR++9TqiDF+hLEEH/h8y96EzUAISt6yelQOsvSRp2Q4CZc843s3WPV+gyUeK JOJejZIpTipgGfNSFnI6LmPeoLZsW+83iCwI5NYBmcKlXMEvror8FS0EQnJd2fmZVg8TDL 77GvxNRT3JlmLzdgGddpz8eDDjwb1/sfJHr5alWloAqj1lE+BSprkXt7bUB4UA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725483257; a=rsa-sha256; cv=none; b=jfsUyzOqGYYf0hv5njfYOKCb07/iz5j1HV1b3canmF+jNRL7tNUYYkHuMvNLcHgTi5jB+z tDtcN0WRIypchiqRtJbpOwjkaL9hbL/V9CSkWF8VBD/6MqfkkP2pcVcGNSeHcCO00bESlX CWn+nvgFpsTGUfj5OKT+2H885acJ4Cr1XmEly74VX9qo3E5uxqc3E9QQA5JqoB0oXfNmWW QlreOR+uH0x3Sk6Vr0w9RlZz9SXRBwQ95t4l6YyANZFFfMCyRtJe7sOO3jYwbzCTIgjd2B Q3mqMxnO+lythZtMP2yxd+D0ODhAc62GvoByo0fyDhzycdzD7r0zmJi2NiGFaw== 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=1725483257; 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=VgsABGMfzIlRaotesFlPasoGAsfntzG69egjUcpYIzg=; b=Xz8raQYp9YUZYB3JSOU/5/VhYfNCKRXJOmITgEJfAD/4A2VUBrA+l8/PSoHzLbymWG+KhQ rlpmvuGuoF5jFaq9MPA/aVjOaS/GZKdWXW+rdfRZGfcRTNiZmBqaa98P79hQoXNWFVsPP2 RlNLkHiP70nyW4vjc1ISVtzUOxHefQGu+1kYPRJDMyiGG2SonuaJ3d2QDp0PKegKLS9WLr dyBn/1wgXbyit6QwwEopbjg2jxovqtefsGD5kGYoclOuzDBg1u79bdgqtIIapYaQLRaW+0 W93nvld6/dpEu7dG6QP/D+FilYEGwAHNJuHNB2PVwkYxqEdPi8TkghMYJMGhzA== 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 4WzZVK07GVzgH1; Wed, 4 Sep 2024 20:54:17 +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 484KsG2C033880; Wed, 4 Sep 2024 20:54:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484KsGwQ033877; Wed, 4 Sep 2024 20:54:16 GMT (envelope-from git) Date: Wed, 4 Sep 2024 20:54:16 GMT Message-Id: <202409042054.484KsGwQ033877@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: 9a77f052cab7 - releng/14.0 - 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.0 X-Git-Reftype: branch X-Git-Commit: 9a77f052cab78165b39e6c6c392381991167e21c Auto-Submitted: auto-generated The branch releng/14.0 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=9a77f052cab78165b39e6c6c392381991167e21c commit 9a77f052cab78165b39e6c6c392381991167e21c Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:12 +0000 Commit: Ed Maste CommitDate: 2024-09-04 20:54:02 +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 f48fc203b90d..5f5987e515c0 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,