From nobody Wed Sep 04 14:46:18 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 4WzQKl14Nyz5V2fj; Wed, 04 Sep 2024 14:46:19 +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 4WzQKk6dFtz4GPp; Wed, 4 Sep 2024 14:46:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725461178; 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=eyKwLtVKOIcP7rPOtN2vZKN8MB05WYszULgBRRTLojY=; b=c/X90jpSj7zPN86r9Wgg+4e/V8C/CH5vvDsIueKrF7lAWMWf2QWO2SwNxRPt9nxx2CF9vg VQSIS3CmJXQNuacZcLv1qcFSmqfQx4MIyzAalqNvk/A6NrQ6LOUWJmim4VjLc220nCDSa5 UsxSHNM9bPqYcT7eFxXvSSn/0ud4vwJPIFp15yB/Bn4711uiIWOPOTMneKTcvuSeGw2oOg 3CFMJKhG2OGVfPkMppt5CRjStoAY1oB2BTwPxeOiUW/ehjlhNHYd1mdQZCl2RVdrqh4Gac 3y7L670grJQaLHqP0+bMP/3slhDotPZ4uk+ovzYN0MwxyXHVsSFJuo8l/RAS/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725461178; a=rsa-sha256; cv=none; b=L1IpEo13qZML7/bcNRbtktrp5m8GE6ce33bz7f2ZOD6ndML8kCNXsQRSZRXNNklf+Y9Q6k /gnquwP4yl/h1/9zdQQ0yx7qKG7BqTr7SbGAU955IlP0CwTd+tfRVNrsgXhgy0ylJBXXpF pM7mD3YII/8NRE8UrYcJ4nZXJyfxDVD8pbghUAy1/itDRxLa71gCNFO98CCmME9Tk0Yvwy a4FdbWZ+110qCjYkf8x7Mp2Kp0gVvCUxqC016CPZhrQ7ldv4F8H5McfWyldSTrFLor1CaB IoaIpSHl7RYi9cg/fbmYY9RhiLITzpIuxCxzHFJfC7yaVnDfeFYWdoGqg07RmQ== 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=1725461178; 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=eyKwLtVKOIcP7rPOtN2vZKN8MB05WYszULgBRRTLojY=; b=vvR8/ArbrUGwaSaNevqCPMIUL5cO7waIUqXlMwTM3Tb9FaP5ql6EKVHJ18/NNYBFC0Ty+9 l9C9+BVG9q4hVPyTRrtKxzGmQOOgr0Iyz1NeQE/f43D0FxJRAo7LnfIaj+Cg3+7WtfAaq4 xR/dtmgiJFb2xJJkHy6fyIptrB/VkIhDpyhSgTmKkObkwEN4N7I9RHUqWJsFiamoUjVZdr wBNEnFCVZF+dGYd9rXOUOHlqsTnMKio5sUyQ1OAxz6FC0L6TCH0r+mbXizM1ysdqK742xY R4di1D2z6GFxQc0Gc3bYGzGSiQOMIcEosbK48ebLwRm8YKQPKGkU8ov3hGYfNw== 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 4WzQKk5MgkzSk0; Wed, 4 Sep 2024 14:46:18 +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 484EkIt6000823; Wed, 4 Sep 2024 14:46:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484EkIgb000820; Wed, 4 Sep 2024 14:46:18 GMT (envelope-from git) Date: Wed, 4 Sep 2024 14:46:18 GMT Message-Id: <202409041446.484EkIgb000820@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: af438acbfde3 - main - 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/main X-Git-Reftype: branch X-Git-Commit: af438acbfde3d25dbdc82b2b3d72380f0191e9d9 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=af438acbfde3d25dbdc82b2b3d72380f0191e9d9 commit af438acbfde3d25dbdc82b2b3d72380f0191e9d9 Author: Pierre Pronchery AuthorDate: 2024-09-04 14:38:12 +0000 Commit: Ed Maste CommitDate: 2024-09-04 14:38:12 +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 --- 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 e58299951540..53858edc2a1d 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -7470,20 +7470,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,