public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Max Gurtovoy <mgurtovoy@nvidia.com>,
	Varun Prakash <varun@chelsio.com>,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] cxgbit_target: Reject immediate data underflow larger than SCSI transfer length
Date: Tue, 7 Jun 2022 12:14:53 -0500	[thread overview]
Message-ID: <84819d83-7e96-be79-649e-e367592ca05a@oracle.com> (raw)
In-Reply-To: <20220607143035.29541-1-xiaohuizhang@ruc.edu.cn>

On 6/7/22 9:30 AM, Xiaohui Zhang wrote:
> Similar to the handling of iscsit_get_immediate_data in commit abb85a9b512e
> ("iscsi-target: Reject immediate data underflow larger than SCSI transfer length"),
> we thought a patch might be needed here as well.
> 
> Signed-off-by: Xiaohui Zhang <xiaohuizhang@ruc.edu.cn>
> ---
>  drivers/target/iscsi/cxgbit/cxgbit_target.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> index acfc39683c87..800bec4b1e88 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> @@ -920,6 +920,18 @@ cxgbit_get_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
>  	 */
>  	if (dump_payload)
>  		goto after_immediate_data;
> +	/*
> +	 * Check for underflow case where both EDTL and immediate data payload
> +	 * exceeds what is presented by CDB's TRANSFER LENGTH, and what has
> +	 * already been set in target_cmd_size_check() as se_cmd->data_length.
> +	 *
> +	 * For this special case, fail the command and dump the immediate data
> +	 * payload.
> +	 */
> +	if (cmd->first_burst_len > cmd->se_cmd.data_length) {
> +		cmd->sense_reason = TCM_INVALID_CDB_FIELD;
> +		goto after_immediate_data;
> +	}
>  

Do you need something like Bart's patch:

commit 4b3766ec0e1840f45bc9238e7e749922bdcb7016
Author: Bart Van Assche <bvanassche@acm.org>
Date:   Tue Apr 2 12:58:15 2019 -0700

    scsi: target/iscsi: Make sure PDU processing continues if parsing a command fails

with your patch or does cxgb avoid that somehow?

      reply	other threads:[~2022-06-07 17:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 14:30 [PATCH 1/1] cxgbit_target: Reject immediate data underflow larger than SCSI transfer length Xiaohui Zhang
2022-06-07 17:14 ` Mike Christie [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84819d83-7e96-be79-649e-e367592ca05a@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=target-devel@vger.kernel.org \
    --cc=varun@chelsio.com \
    --cc=xiaohuizhang@ruc.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox