From nobody Mon Oct 21 14:54:26 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 4XXJHQ7369z5ZNKt; Mon, 21 Oct 2024 14:54:26 +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 4XXJHQ6GsPz4byh; Mon, 21 Oct 2024 14:54:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729522466; 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=8DcRIhFEK63TC/5u99G+XKiUO0KL2guIXGb/1fF0GnE=; b=KS7yFy4C6JBvQdGsC//x2mttkDBW1nf9OPLZuvnXnnf3Ekf/tbYrrRFEbyJnTlb3Yk8iiB +df3Fr1iDWrJdSO3vRrEsrGphB8MERmd7c5hekJA7kMbkwxM4g9Z4Mkt4rtVOoZElwyuRe +x7TXocT80QT1Ya3x/xcPUF69EqNJFAuI0cBbQ0Yr2q8fl9W5mSMIMWH0thcNpCpED25GR 9Yt02nohHSmP+AE4I7le79+yCKd1lPGBDiorQbpNJR0OF00I6yOQWAQ2GUTHFQ6WtMbLpb uOXkt0shODQP6wE53j4v+J6UhduBH6Wo2r3LYpwGDdQBImqjbQx2NcdV9ozf8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729522466; 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=8DcRIhFEK63TC/5u99G+XKiUO0KL2guIXGb/1fF0GnE=; b=KcOg9iSGHYK+XYL+AfnT7tYD+in3/Wo9lbiM/ZKfwpPlwGpnbd6N/DK3NyMfAqMUdgElfq iOTz3tEY8gNKYnZalJW2dnPMdYmP6ODCKE/BfdBKJws50Yelp32ZxPIAouzInIINX6htSV siEvG34Fw0GRJghMeH+q/k09Jg5lVwr8bYeBgg42kLEZDq9BGKPYFV+2p8CWC6KLCAJn6/ 0NKMaLUoEXUiFlk5J/oQdQglNlIJAXswBWOCcOtwfGr8ZU9LCYynBSGisKqHqlA1hUoCPo NIN2HcqE4CSfoEOlKNjKttoDhspga5uZ+vDltKZo1YJpBiCkJPr3v/6N5FgS0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729522466; a=rsa-sha256; cv=none; b=kyYA4kCCAi3YA1dsGgxMY1n1R9DZRilwEXKpOGMtwcTcQUEG3oEYOuXmhOWkjafwL4Fy+/ J6qK8JRpq9BHJs6lwScZUJd3wAx8jWCaxTg8WqS3l9wGVKkcdr1HTH/+jomT5PWcAwZTnA 51DK6y4glnud12ibuUaRelnTgLXSDcclGxx9monKwVme+lvxYC5E+RioFNdk1ta+YKyX9v RpFxrPA5NAKxYvgjxJyCo+oSPy/ufacsz3H+ZUcrbxAK7QABcpWengAcVn4QzVoUDW+U/i nSiJByM4/OZmUxZJ0z01+WemH6KaguXM8LJbV4MYwA1x5zVQmsBu+YpIzbo0xw== 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 4XXJHQ5mYSzZ0q; Mon, 21 Oct 2024 14:54:26 +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 49LEsQVS026065; Mon, 21 Oct 2024 14:54:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49LEsQLd026061; Mon, 21 Oct 2024 14:54:26 GMT (envelope-from git) Date: Mon, 21 Oct 2024 14:54:26 GMT Message-Id: <202410211454.49LEsQLd026061@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 0e3a21196101 - main - ctl_report_supported_opcodes: Handle invalid requested service action 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0e3a211961014e0991a54f583b2866ac19ed0e76 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=0e3a211961014e0991a54f583b2866ac19ed0e76 commit 0e3a211961014e0991a54f583b2866ac19ed0e76 Author: John Baldwin AuthorDate: 2024-10-21 14:53:48 +0000 Commit: John Baldwin CommitDate: 2024-10-21 14:53:48 +0000 ctl_report_supported_opcodes: Handle invalid requested service action Service actions are only valid up to 31 as they are encoded in the low 5 bits of byte 1 in CDBs. Fail requests with a requested service action of 32 or higher with an INVALID FIELD IN COMMAND specifying byte 4 as the illegal byte. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D46611 --- sys/cam/ctl/ctl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c index da147f0ec914..6533bf98011c 100644 --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -7461,16 +7461,20 @@ ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; break; case RSO_OPTIONS_OC_SA: - if ((ctl_cmd_table[opcode].flags & CTL_CMD_FLAG_SA5) == 0 || - service_action >= 32) { + if ((ctl_cmd_table[opcode].flags & CTL_CMD_FLAG_SA5) == 0) { goto invalid_options; } - total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; - break; + /* FALLTHROUGH */ case RSO_OPTIONS_OC_ASA: - if ((ctl_cmd_table[opcode].flags & CTL_CMD_FLAG_SA5) != 0 && - service_action >= 32) { - goto invalid_options; + if (service_action >= 32) { + ctl_set_invalid_field(/*ctsio*/ ctsio, + /*sks_valid*/ 1, + /*command*/ 1, + /*field*/ 4, + /*bit_valid*/ 0, + /*bit*/ 0); + ctl_done((union ctl_io *)ctsio); + return (CTL_RETVAL_COMPLETE); } total_len = sizeof(struct scsi_report_supported_opcodes_one) + 32; break;